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
|
|
|
|
2023-03-02 00:38:40 +08:00
|
|
|
export default async 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,
|
|
|
|
};
|
2023-03-02 00:38:40 +08:00
|
|
|
const numberAffected = Breakouts.updateAsync(selector, modifier, options);
|
|
|
|
|
|
|
|
if (numberAffected) {
|
|
|
|
Logger.info(`Updated breakout time remaining for breakouts where parentMeetingId=${meetingId}`);
|
|
|
|
} else {
|
|
|
|
Logger.error(`Updating breakouts: ${numberAffected}`);
|
|
|
|
}
|
2016-11-14 19:57:10 +08:00
|
|
|
}
|