summary refs log tree commit diff
path: root/src/api/util
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-09-28 23:36:26 +0200
committerRory& <root@rory.gay>2025-09-29 18:38:06 +0200
commit871880996bb1ce98e2018c1a124da0bd4af81bae (patch)
treeb6d9245a5e4f028dba264382b3817240b8ed5f43 /src/api/util
parentInclude referenced_message relation on GET /channel/.../messages (diff)
downloadserver-ts-871880996bb1ce98e2018c1a124da0bd4af81bae.tar.xz
Actually set the referenced_message relation on new messages
Diffstat (limited to 'src/api/util')
-rw-r--r--src/api/util/handlers/Message.ts9
1 files changed, 8 insertions, 1 deletions
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<Message> { 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.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 **/