diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-10-18 18:34:48 +0200 |
---|---|---|
committer | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-10-18 18:34:48 +0200 |
commit | 923d4d23046670244f9c2e4b8b1f7e76566704f4 (patch) | |
tree | 72221ca17499d1081dd184a5626ca5af88424927 /api/src/routes | |
parent | :globe_with_meridians: remove unused locales (diff) | |
download | server-923d4d23046670244f9c2e4b8b1f7e76566704f4.tar.xz |
:zap: message performance
Diffstat (limited to 'api/src/routes')
-rw-r--r-- | api/src/routes/channels/#channel_id/messages/index.ts | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/api/src/routes/channels/#channel_id/messages/index.ts b/api/src/routes/channels/#channel_id/messages/index.ts index a0834be0..d3c0a409 100644 --- a/api/src/routes/channels/#channel_id/messages/index.ts +++ b/api/src/routes/channels/#channel_id/messages/index.ts @@ -186,14 +186,13 @@ router.post( timestamp: new Date() }); - message = await message.save(); + channel.last_message_id = message.id; if (channel.isDm()) { const channel_dto = await DmChannelDTO.from(channel); - //Only one recipients should be closed here, since in group DMs the recipient is deleted not closed - - await Promise.all( + // Only one recipients should be closed here, since in group DMs the recipient is deleted not closed + Promise.all( channel.recipients!.map((recipient) => { if (recipient.closed) { recipient.closed = false; @@ -211,9 +210,10 @@ router.post( } await Promise.all([ - channel.assign({ last_message_id: message.id }).save(), + message.save(), + emitEvent({ event: "MESSAGE_CREATE", channel_id: channel_id, data: message } as MessageCreateEvent), message.guild_id ? Member.update({ id: req.user_id, guild_id: message.guild_id }, { last_message_id: message.id }) : null, - emitEvent({ event: "MESSAGE_CREATE", channel_id: channel_id, data: message } as MessageCreateEvent) + channel.save() ]); postHandleMessage(message).catch((e) => {}); // no await as it shouldnt block the message send function and silently catch error |