2016-11-15 00:12:54 +08:00
|
|
|
import { check } from 'meteor/check';
|
2017-10-12 05:25:18 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
2017-10-12 10:00:28 +08:00
|
|
|
import Breakouts from '/imports/api/breakouts';
|
2016-11-14 19:57:10 +08:00
|
|
|
|
2017-10-12 05:25:18 +08:00
|
|
|
export default function handleUpdateTimeRemaining({ body }, meetingId) {
|
2016-11-15 00:12:54 +08:00
|
|
|
const {
|
|
|
|
timeRemaining,
|
2017-10-12 05:25:18 +08:00
|
|
|
} = body;
|
2016-11-15 00:12:54 +08:00
|
|
|
|
|
|
|
check(meetingId, String);
|
|
|
|
check(timeRemaining, Number);
|
|
|
|
|
2016-11-14 19:57:10 +08:00
|
|
|
const selector = {
|
2016-11-29 03:48:02 +08:00
|
|
|
parentMeetingId: meetingId,
|
2016-11-14 19:57:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const modifier = {
|
|
|
|
$set: {
|
2017-06-03 03:25:02 +08:00
|
|
|
timeRemaining,
|
2016-11-14 19:57:10 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2016-11-24 00:13:41 +08:00
|
|
|
const options = {
|
|
|
|
multi: true,
|
|
|
|
};
|
|
|
|
|
2020-11-27 00:23:57 +08:00
|
|
|
try {
|
|
|
|
const numberAffected = Breakouts.update(selector, modifier, options);
|
2016-11-24 00:18:36 +08:00
|
|
|
|
2020-11-27 00:23:57 +08:00
|
|
|
if (numberAffected) {
|
|
|
|
Logger.info(`Updated breakout time remaining for breakouts where parentMeetingId=${meetingId}`);
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Updating breakouts: ${err}`);
|
|
|
|
}
|
2016-11-14 19:57:10 +08:00
|
|
|
}
|