diff --git a/src/api/routes/applications/#application_id/bot/index.ts b/src/api/routes/applications/#application_id/bot/index.ts index f494c2e3f..27b6b9c17 100644 --- a/src/api/routes/applications/#application_id/bot/index.ts +++ b/src/api/routes/applications/#application_id/bot/index.ts @@ -67,8 +67,9 @@ router.post( }, }), async (req: Request, res: Response) => { + const app = await Application.findOneOrFail({ where: { id: req.params.application_id as string } }); const bot = await User.findOneOrFail({ where: { id: req.params.application_id as string } }); - const owner = req.user; + const owner = await User.findOneOrFail({ where: { id: app.owner_id }, select: { id: true, totp_secret: true } }); if (owner.id != req.user_id) throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION; diff --git a/src/api/util/utility/polls.ts b/src/api/util/utility/polls.ts index 48c941219..bea5cd50b 100644 --- a/src/api/util/utility/polls.ts +++ b/src/api/util/utility/polls.ts @@ -22,7 +22,8 @@ import { MessageOptions, sendMessage } from "../handlers/Message"; import { Message } from "@spacebar/database"; export async function generatePollResultsMessage(options: MessageOptions): Promise { - const message = await Message.create({ + // TODO: shouldnt this get saved? + const message = Message.create({ ...options, message_reference: options.message_reference ?? undefined, poll: options.poll,