bigbluebutton-Github/bigbluebutton-html5/imports/api/timer/server/methods/startTimer.js

27 lines
701 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 updateTimer from '/imports/api/timer/server/modifiers/updateTimer';
import { extractCredentials } from '/imports/api/common/server/helpers';
export default function startTimer(time) {
check(time, Number);
const { meetingId } = extractCredentials(this.userId);
check(meetingId, String);
const timer = Timer.findOne(
{ meetingId },
{ fields: { time: 1 } },
);
if (timer) {
if (time !== timer.time) {
updateTimer('start', meetingId, time);
} else {
updateTimer('resume', meetingId);
}
} else {
Logger.warn(`Could not start timer for meetingId=${meetingId}`);
}
}