2017-06-19 19:57:32 +08:00
|
|
|
import Breakouts from '/imports/api/1.1/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';
|
2016-11-14 19:57:10 +08:00
|
|
|
|
2016-11-30 00:52:15 +08:00
|
|
|
export default function handleBreakoutRoomStarted({ payload }) {
|
2016-11-29 03:48:02 +08:00
|
|
|
const {
|
|
|
|
meetingId,
|
|
|
|
timeRemaining,
|
|
|
|
externalMeetingId,
|
|
|
|
} = payload;
|
2016-11-15 00:12:54 +08:00
|
|
|
|
|
|
|
check(meetingId, String);
|
|
|
|
|
2016-11-14 19:57:10 +08:00
|
|
|
const selector = {
|
2016-11-29 03:48:02 +08:00
|
|
|
breakoutMeetingId: meetingId,
|
2016-11-14 19:57:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
modifier = {
|
|
|
|
$set: {
|
|
|
|
users: [],
|
2016-11-29 03:48:02 +08:00
|
|
|
timeRemaining: Number(timeRemaining),
|
2017-06-03 03:25:02 +08:00
|
|
|
externalMeetingId,
|
2016-11-14 19:57:10 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const cb = (err, numChanged) => {
|
|
|
|
if (err) {
|
2016-11-29 03:48:02 +08:00
|
|
|
return Logger.error(`updating breakout: ${err}`);
|
2016-11-14 19:57:10 +08:00
|
|
|
}
|
|
|
|
|
2016-11-29 03:48:02 +08:00
|
|
|
if (numChanged) {
|
2017-06-03 03:25:02 +08:00
|
|
|
return Logger.info('Updated timeRemaining and externalMeetingId ' +
|
2016-11-29 03:48:02 +08:00
|
|
|
`for breakout id=${meetingId}`);
|
2016-11-14 19:57:10 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-11-30 00:52:15 +08:00
|
|
|
return Breakouts.update(selector, modifier, cb);
|
2016-11-14 19:57:10 +08:00
|
|
|
}
|