From 871880996bb1ce98e2018c1a124da0bd4af81bae Mon Sep 17 00:00:00 2001 From: Rory& Date: Sun, 28 Sep 2025 23:36:26 +0200 Subject: [PATCH] Actually set the referenced_message relation on new messages --- src/api/util/handlers/Message.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/api/util/handlers/Message.ts b/src/api/util/handlers/Message.ts index 7141ff17..90df9a78 100644 --- a/src/api/util/handlers/Message.ts +++ b/src/api/util/handlers/Message.ts @@ -106,7 +106,7 @@ export async function handleMessage(opts: MessageOptions): Promise { const cloneResponse = await fetch(`${Config.get().cdn.endpointPrivate}/attachments/${attEnt.uploadFilename}/clone_to_message/${message.id}`, { method: "POST", headers: { - "signature": Config.get().security.requestSignature || "", + signature: Config.get().security.requestSignature || "", }, }); @@ -223,6 +223,13 @@ export async function handleMessage(opts: MessageOptions): Promise { } message.message_reference = opts.message_reference; + message.referenced_message = await Message.findOneOrFail({ + where: { + id: opts.message_reference.message_id, + }, + }); + + if (message.referenced_message.channel_id !== opts.message_reference.channel_id) throw new HTTPError("Referenced message not found in the specified channel", 404); } /** Q: should be checked if the referenced message exists? ANSWER: NO otherwise backfilling won't work **/