Merge pull request #10865 from jfsiebel/handle-chat-message-in-order

Handle chat messages in sync way
This commit is contained in:
Anton Georgiev 2020-11-19 09:31:11 -05:00 committed by GitHub
commit a947977c66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 13 deletions

View File

@ -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);
}

View File

@ -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}`);
}
return Logger.info(`Upserted group-chat-msg msgId=${msg.id} chatId=${chatId} meetingId=${meetingId}`);
};
return GroupChatMsg.upsert(selector, modifier, cb);
} catch (err) {
Logger.error(`Adding group-chat-msg to collection: ${err}`);
}
}