bigbluebutton-Github/bigbluebutton-html5/imports/api/presentation-upload-token/server/methods/setUsedToken.js

33 lines
934 B
JavaScript

import PresentationUploadToken from '/imports/api/presentation-upload-token';
import Logger from '/imports/startup/server/logger';
import { extractCredentials } from '/imports/api/common/server/helpers';
import { check } from 'meteor/check';
export default async function setUsedToken(authzToken) {
try {
const { meetingId, requesterUserId } = extractCredentials(this.userId);
check(meetingId, String);
check(requesterUserId, String);
check(authzToken, String);
const payload = {
$set: {
used: true,
},
};
const numberAffected = await PresentationUploadToken.updateAsync({
meetingId,
userId: requesterUserId,
authzToken,
}, payload);
if (numberAffected) {
Logger.info(`Token: ${authzToken} has been set as used in meeting=${meetingId}`);
}
} catch (err) {
Logger.error(`Exception while invoking method setUsedToken ${err.stack}`);
}
}