Merge pull request #10865 from jfsiebel/handle-chat-message-in-order
Handle chat messages in sync way
This commit is contained in:
commit
a947977c66
@ -8,5 +8,5 @@ export default function handleGroupChatMsgBroadcast({ body }, meetingId) {
|
||||
check(chatId, String);
|
||||
check(msg, Object);
|
||||
|
||||
return addGroupChatMsg(meetingId, chatId, msg);
|
||||
addGroupChatMsg(meetingId, chatId, msg);
|
||||
}
|
||||
|
@ -47,19 +47,15 @@ export default function addGroupChatMsg(meetingId, chatId, msg) {
|
||||
$set: flat(msgDocument, { safe: true }),
|
||||
};
|
||||
|
||||
const cb = (err, numChanged) => {
|
||||
if (err) {
|
||||
return Logger.error(`Adding group-chat-msg to collection: ${err}`);
|
||||
}
|
||||
|
||||
const { insertedId } = numChanged;
|
||||
try {
|
||||
const { insertedId } = GroupChatMsg.upsert(selector, modifier);
|
||||
|
||||
if (insertedId) {
|
||||
return Logger.info(`Added group-chat-msg msgId=${msg.id} chatId=${chatId} meetingId=${meetingId}`);
|
||||
Logger.info(`Added group-chat-msg msgId=${msg.id} chatId=${chatId} meetingId=${meetingId}`);
|
||||
} else {
|
||||
Logger.info(`Upserted group-chat-msg msgId=${msg.id} chatId=${chatId} meetingId=${meetingId}`);
|
||||
}
|
||||
} catch (err) {
|
||||
Logger.error(`Adding group-chat-msg to collection: ${err}`);
|
||||
}
|
||||
|
||||
return Logger.info(`Upserted group-chat-msg msgId=${msg.id} chatId=${chatId} meetingId=${meetingId}`);
|
||||
};
|
||||
|
||||
return GroupChatMsg.upsert(selector, modifier, cb);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user