2019-07-12 01:46:44 +08:00
|
|
|
import PresentationUploadToken from '/imports/api/presentation-upload-token';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
2020-02-07 04:47:28 +08:00
|
|
|
import { extractCredentials } from '/imports/api/common/server/helpers';
|
2019-07-12 01:46:44 +08:00
|
|
|
|
2020-02-07 04:47:28 +08:00
|
|
|
export default function setUsedToken(authzToken) {
|
|
|
|
const { meetingId, requesterUserId } = extractCredentials(this.userId);
|
2019-07-12 01:46:44 +08:00
|
|
|
|
|
|
|
const payload = {
|
|
|
|
$set: {
|
|
|
|
used: true,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
const cb = (err) => {
|
|
|
|
if (err) {
|
|
|
|
Logger.error(`Unable to set token as used : ${err}`);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-07-19 00:27:23 +08:00
|
|
|
Logger.info(`Token: ${authzToken} has been set as used in meeting=${meetingId}`);
|
2019-07-12 01:46:44 +08:00
|
|
|
};
|
|
|
|
|
2019-07-19 02:42:35 +08:00
|
|
|
return PresentationUploadToken.update({
|
|
|
|
meetingId,
|
|
|
|
userId: requesterUserId,
|
|
|
|
authzToken,
|
|
|
|
}, payload, cb);
|
2019-07-12 01:46:44 +08:00
|
|
|
}
|