2017-10-12 10:00:28 +08:00
|
|
|
import Breakouts from '/imports/api/breakouts';
|
2016-11-14 19:57:10 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
2016-11-15 00:12:54 +08:00
|
|
|
import { check } from 'meteor/check';
|
2017-10-12 05:25:18 +08:00
|
|
|
import flat from 'flat';
|
2016-11-14 19:57:10 +08:00
|
|
|
|
2017-10-12 05:25:18 +08:00
|
|
|
export default function handleBreakoutRoomStarted({ body }, meetingId) {
|
2018-06-12 00:00:43 +08:00
|
|
|
// 0 seconds default breakout time, forces use of real expiration time
|
|
|
|
const DEFAULT_TIME_REMAINING = 0;
|
2018-06-11 23:50:38 +08:00
|
|
|
|
2016-11-29 03:48:02 +08:00
|
|
|
const {
|
2017-10-12 05:25:18 +08:00
|
|
|
parentMeetingId,
|
|
|
|
breakout,
|
|
|
|
} = body;
|
|
|
|
|
|
|
|
const { breakoutId } = breakout;
|
|
|
|
|
2016-11-15 00:12:54 +08:00
|
|
|
check(meetingId, String);
|
|
|
|
|
2016-11-14 19:57:10 +08:00
|
|
|
const selector = {
|
2017-10-12 05:25:18 +08:00
|
|
|
breakoutId,
|
2016-11-14 19:57:10 +08:00
|
|
|
};
|
|
|
|
|
2017-10-12 05:25:18 +08:00
|
|
|
const modifier = {
|
|
|
|
$set: Object.assign(
|
2019-05-01 03:24:04 +08:00
|
|
|
{
|
|
|
|
users: [],
|
|
|
|
joinedUsers: [],
|
|
|
|
},
|
2018-06-11 23:50:38 +08:00
|
|
|
{ timeRemaining: DEFAULT_TIME_REMAINING },
|
2017-10-12 05:25:18 +08:00
|
|
|
{ parentMeetingId },
|
|
|
|
flat(breakout),
|
|
|
|
),
|
2016-11-14 19:57:10 +08:00
|
|
|
};
|
|
|
|
|
2017-10-12 05:25:18 +08:00
|
|
|
const cb = (err) => {
|
2016-11-14 19:57:10 +08:00
|
|
|
if (err) {
|
2016-11-29 03:48:02 +08:00
|
|
|
return Logger.error(`updating breakout: ${err}`);
|
2016-11-14 19:57:10 +08:00
|
|
|
}
|
|
|
|
|
2019-05-01 03:24:04 +08:00
|
|
|
return Logger.info('Updated timeRemaining and externalMeetingId '
|
|
|
|
+ `for breakout id=${breakoutId}`);
|
2016-11-14 19:57:10 +08:00
|
|
|
};
|
|
|
|
|
2017-10-12 05:25:18 +08:00
|
|
|
return Breakouts.upsert(selector, modifier, cb);
|
2016-11-14 19:57:10 +08:00
|
|
|
}
|