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

42 lines
934 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) {
const DEFAULT_TIME_REMAINING = 15 * 60; // 15 minutes default breakout time
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: [] },
{ 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
}