2019-05-01 03:24:04 +08:00
|
|
|
import Breakouts from '/imports/api/breakouts';
|
2021-11-11 21:10:31 +08:00
|
|
|
import updateUserBreakoutRoom from '../../../users-persistent-data/server/modifiers/updateUserBreakoutRoom';
|
2019-05-01 03:24:04 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
import { check } from 'meteor/check';
|
|
|
|
|
|
|
|
export default function joinedUsersChanged({ body }) {
|
|
|
|
check(body, Object);
|
|
|
|
|
|
|
|
const {
|
|
|
|
parentId,
|
|
|
|
breakoutId,
|
|
|
|
users,
|
|
|
|
} = body;
|
|
|
|
|
|
|
|
check(parentId, String);
|
|
|
|
check(breakoutId, String);
|
|
|
|
check(users, Array);
|
|
|
|
|
|
|
|
const selector = {
|
|
|
|
parentMeetingId: parentId,
|
|
|
|
breakoutId,
|
|
|
|
};
|
|
|
|
|
|
|
|
const usersMapped = users.map(user => ({ userId: user.id, name: user.name }));
|
|
|
|
const modifier = {
|
|
|
|
$set: {
|
|
|
|
joinedUsers: usersMapped,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-11-27 00:23:57 +08:00
|
|
|
try {
|
|
|
|
const numberAffected = Breakouts.update(selector, modifier);
|
2019-05-01 03:24:04 +08:00
|
|
|
|
2020-11-27 00:23:57 +08:00
|
|
|
if (numberAffected) {
|
2021-11-11 21:10:31 +08:00
|
|
|
updateUserBreakoutRoom(parentId, breakoutId, users);
|
|
|
|
|
2020-11-27 00:23:57 +08:00
|
|
|
Logger.info(`Updated joined users in breakout id=${breakoutId}`);
|
2019-05-01 03:24:04 +08:00
|
|
|
}
|
2020-11-27 00:23:57 +08:00
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`updating joined users in breakout: ${err}`);
|
|
|
|
}
|
2019-05-01 03:24:04 +08:00
|
|
|
}
|