mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-10 20:52:42 +01:00
⚡ message performance
This commit is contained in:
parent
374c3f7bb2
commit
923d4d2304
@ -186,14 +186,13 @@ router.post(
|
|||||||
timestamp: new Date()
|
timestamp: new Date()
|
||||||
});
|
});
|
||||||
|
|
||||||
message = await message.save();
|
channel.last_message_id = message.id;
|
||||||
|
|
||||||
if (channel.isDm()) {
|
if (channel.isDm()) {
|
||||||
const channel_dto = await DmChannelDTO.from(channel);
|
const channel_dto = await DmChannelDTO.from(channel);
|
||||||
|
|
||||||
//Only one recipients should be closed here, since in group DMs the recipient is deleted not closed
|
// Only one recipients should be closed here, since in group DMs the recipient is deleted not closed
|
||||||
|
Promise.all(
|
||||||
await Promise.all(
|
|
||||||
channel.recipients!.map((recipient) => {
|
channel.recipients!.map((recipient) => {
|
||||||
if (recipient.closed) {
|
if (recipient.closed) {
|
||||||
recipient.closed = false;
|
recipient.closed = false;
|
||||||
@ -211,9 +210,10 @@ router.post(
|
|||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all([
|
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,
|
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
|
postHandleMessage(message).catch((e) => {}); // no await as it shouldnt block the message send function and silently catch error
|
||||||
|
@ -184,7 +184,7 @@ export async function sendMessage(opts: MessageOptions) {
|
|||||||
const message = await handleMessage({ ...opts, timestamp: new Date() });
|
const message = await handleMessage({ ...opts, timestamp: new Date() });
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
message.save(),
|
Message.insert(message),
|
||||||
emitEvent({ event: "MESSAGE_CREATE", channel_id: opts.channel_id, data: message.toJSON() } as MessageCreateEvent)
|
emitEvent({ event: "MESSAGE_CREATE", channel_id: opts.channel_id, data: message.toJSON() } as MessageCreateEvent)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user