2018-09-05 00:56:10 +08:00
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
import PresentationUploadToken from '/imports/api/presentation-upload-token';
|
|
|
|
|
|
|
|
export default function handlePresentationUploadTokenPass({ body, header }, meetingId) {
|
|
|
|
check(body, Object);
|
|
|
|
|
|
|
|
const { userId } = header;
|
2022-08-22 20:21:33 +08:00
|
|
|
const { podId, authzToken, filename, temporaryPresentationId } = body;
|
2018-09-05 00:56:10 +08:00
|
|
|
|
|
|
|
check(userId, String);
|
|
|
|
check(podId, String);
|
|
|
|
check(authzToken, String);
|
|
|
|
check(filename, String);
|
2022-08-22 20:21:33 +08:00
|
|
|
check(temporaryPresentationId, String)
|
2018-09-05 00:56:10 +08:00
|
|
|
|
|
|
|
const selector = {
|
|
|
|
meetingId,
|
|
|
|
podId,
|
|
|
|
userId,
|
|
|
|
filename,
|
2022-08-22 20:21:33 +08:00
|
|
|
temporaryPresentationId,
|
2018-09-05 00:56:10 +08:00
|
|
|
};
|
|
|
|
|
2020-11-25 21:54:18 +08:00
|
|
|
const modifier = {
|
2018-09-05 00:56:10 +08:00
|
|
|
meetingId,
|
|
|
|
podId,
|
|
|
|
userId,
|
|
|
|
filename,
|
|
|
|
authzToken,
|
2022-08-22 20:21:33 +08:00
|
|
|
temporaryPresentationId,
|
2018-09-05 00:56:10 +08:00
|
|
|
failed: false,
|
2019-07-12 01:46:44 +08:00
|
|
|
used: false,
|
2018-09-05 00:56:10 +08:00
|
|
|
};
|
|
|
|
|
2020-11-25 21:54:18 +08:00
|
|
|
try {
|
|
|
|
const { insertedId } = PresentationUploadToken.upsert(selector, modifier);
|
2018-09-05 00:56:10 +08:00
|
|
|
|
2020-11-25 21:54:18 +08:00
|
|
|
if (insertedId) {
|
|
|
|
Logger.info(`Inserting presentationToken filename=${filename} podId=${podId} meeting=${meetingId}`);
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Inserting presentationToken from collection: ${err}`);
|
|
|
|
}
|
2018-09-05 00:56:10 +08:00
|
|
|
}
|