bigbluebutton-Github/bigbluebutton-html5/imports/api/timer/server/modifiers/addTimer.js

35 lines
806 B
JavaScript
Raw Normal View History

2023-05-11 04:03:20 +08:00
import { check } from 'meteor/check';
import Timer from '/imports/api/timer';
import Logger from '/imports/startup/server/logger';
import { getInitialState } from '/imports/api/timer/server/helpers';
2023-05-11 04:03:20 +08:00
2020-04-26 03:03:35 +08:00
// This method should only be used by the server
2023-05-11 04:03:20 +08:00
export default function addTimer(meetingId) {
check(meetingId, String);
const selector = {
meetingId,
};
const modifier = {
meetingId,
...getInitialState(),
2023-05-11 04:03:20 +08:00
active: false,
ended: 0,
2023-05-11 04:03:20 +08:00
};
const cb = (err, numChanged) => {
if (err) {
return Logger.error(`Adding timer to the collection: ${err}`);
}
if (numChanged) {
2020-04-27 01:44:01 +08:00
return Logger.debug(`Added timer meeting=${meetingId}`);
2023-05-11 04:03:20 +08:00
}
2020-04-27 01:44:01 +08:00
return Logger.debug(`Upserted timer meeting=${meetingId}`);
2023-05-11 04:03:20 +08:00
};
return Timer.upsert(selector, modifier, cb);
}