bigbluebutton-Github/bigbluebutton-html5/imports/api/breakouts/server/handlers/breakoutStarted.js

46 lines
1005 B
JavaScript
Raw Normal View History

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';
import flat from 'flat';
2016-11-14 19:57:10 +08:00
export default function handleBreakoutRoomStarted({ body }, meetingId) {
// 0 seconds default breakout time, forces use of real expiration time
const DEFAULT_TIME_REMAINING = 0;
2016-11-29 03:48:02 +08:00
const {
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 = {
breakoutId,
2016-11-14 19:57:10 +08:00
};
const modifier = {
$set: Object.assign(
{
users: [],
joinedUsers: [],
},
{ timeRemaining: DEFAULT_TIME_REMAINING },
{ parentMeetingId },
flat(breakout),
),
2016-11-14 19:57:10 +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
}
return Logger.info('Updated timeRemaining and externalMeetingId '
+ `for breakout id=${breakoutId}`);
2016-11-14 19:57:10 +08:00
};
return Breakouts.upsert(selector, modifier, cb);
2016-11-14 19:57:10 +08:00
}