fix breakout room multiple invitations

This commit is contained in:
Ramon Souza 2021-09-15 14:43:51 -03:00
parent baa0d0e2bd
commit de53770d77

View File

@ -15,13 +15,26 @@ export default function handleBreakoutJoinURL({ body }) {
breakoutId,
};
// only keep each users' last invitation
const newUsers = [];
const currentBreakout = Breakouts.findOne({ breakoutId }, { fields: { users: 1 } });
currentBreakout.users.forEach((item) => {
if (item.userId !== userId) {
newUsers.push(item);
}
});
newUsers.push({
userId,
redirectToHtml5JoinURL,
insertedTime: new Date().getTime(),
});
const modifier = {
$push: {
users: {
userId,
redirectToHtml5JoinURL,
insertedTime: new Date().getTime(),
},
$set: {
users: newUsers,
},
};