summary refs log tree commit diff
path: root/src/api/util
diff options
context:
space:
mode:
authorMathMan05 <mathmanrm@gmail.com>2026-02-03 17:09:33 -0600
committerMathMan05 <mathmanrm@gmail.com>2026-02-03 17:09:33 -0600
commitdf20d6551eb05728bec99790176c7e413d36e627 (patch)
tree01f4e7b8580a7826b3d01bb80c0169d1fe50b362 /src/api/util
parentsend message to join thread (diff)
downloadserver-ts-df20d6551eb05728bec99790176c7e413d36e627.tar.xz
more changes
Diffstat (limited to 'src/api/util')
-rw-r--r--src/api/util/handlers/Message.ts58
1 files changed, 30 insertions, 28 deletions
diff --git a/src/api/util/handlers/Message.ts b/src/api/util/handlers/Message.ts

index c81de300..22ebf60e 100644 --- a/src/api/util/handlers/Message.ts +++ b/src/api/util/handlers/Message.ts
@@ -248,38 +248,40 @@ 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, - }, - relations: { - author: true, - webhook: true, - application: true, - mentions: true, - mention_roles: true, - mention_channels: true, - sticker_items: true, - attachments: true, - }, - }); + if (message.message_reference.message_id) { + message.referenced_message = await Message.findOneOrFail({ + where: { + id: opts.message_reference.message_id, + }, + relations: { + author: true, + webhook: true, + application: true, + mentions: true, + mention_roles: true, + mention_channels: true, + sticker_items: true, + attachments: true, + }, + }); - if ( - message.referenced_message.channel_id && - message.referenced_message.channel_id !== opts.message_reference.channel_id && - opts.type !== MessageType.THREAD_STARTER_MESSAGE - ) - throw new HTTPError("Referenced message not found in the specified channel", 404); - if ( - message.referenced_message.guild_id && - message.referenced_message.guild_id !== opts.message_reference.guild_id && - opts.type !== MessageType.THREAD_STARTER_MESSAGE - ) - throw new HTTPError("Referenced message not found in the specified channel", 404); + if ( + message.referenced_message.channel_id && + message.referenced_message.channel_id !== opts.message_reference.channel_id && + opts.type !== MessageType.THREAD_STARTER_MESSAGE + ) + throw new HTTPError("Referenced message not found in the specified channel", 404); + if ( + message.referenced_message.guild_id && + message.referenced_message.guild_id !== opts.message_reference.guild_id && + opts.type !== MessageType.THREAD_STARTER_MESSAGE + ) + 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 **/ - if (MessageType.THREAD_STARTER_MESSAGE !== message.type) message.type = MessageType.REPLY; + if (MessageType.THREAD_STARTER_MESSAGE !== message.type && MessageType.THREAD_CREATED !== message.type) message.type = MessageType.REPLY; } }