2022-02-02 03:05:02 +08:00
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import updateTimer from '/imports/api/timer/server/modifiers/updateTimer';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
import { extractCredentials } from '/imports/api/common/server/helpers';
|
|
|
|
import { isTrackValid } from '/imports/api/timer/server/helpers';
|
|
|
|
|
|
|
|
export default function setTrack(track) {
|
|
|
|
const { meetingId, requesterUserId } = extractCredentials(this.userId);
|
|
|
|
check(meetingId, String);
|
2022-07-14 00:59:02 +08:00
|
|
|
check(requesterUserId, String);
|
2022-02-02 03:05:02 +08:00
|
|
|
check(track, String);
|
|
|
|
|
|
|
|
//These are bogus values, won't update collection
|
|
|
|
const time = 0;
|
|
|
|
const stopwatch = false;
|
|
|
|
const accumulated = 0;
|
|
|
|
|
|
|
|
if (isTrackValid(track)) {
|
2022-07-14 00:59:02 +08:00
|
|
|
updateTimer('track', meetingId, requesterUserId, time, stopwatch, accumulated, track);
|
2022-02-02 03:05:02 +08:00
|
|
|
} else {
|
|
|
|
Logger.warn(`User=${requesterUserId} tried to set invalid track '${track}' in meeting=${meetingId}`);
|
|
|
|
}
|
|
|
|
}
|