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) {
|
2016-11-29 03:48:02 +08:00
|
|
|
const {
|
2017-10-12 05:25:18 +08:00
|
|
|
parentMeetingId,
|
|
|
|
breakout,
|
|
|
|
} = body;
|
|
|
|
|
|
|
|
const { breakoutId } = breakout;
|
|
|
|
|
|
|
|
const timeRemaining = 15;
|
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(
|
|
|
|
{ users: [] },
|
|
|
|
{ timeRemaining: Number(timeRemaining) },
|
|
|
|
{ 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
|
|
|
}
|
|
|
|
|
2017-10-12 05:25:18 +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
|
|
|
}
|