2018-09-05 00:56:10 +08:00
|
|
|
import { Meteor } from 'meteor/meteor';
|
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import PresentationUploadToken from '/imports/api/presentation-upload-token';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
2020-09-02 00:31:11 +08:00
|
|
|
import AuthTokenValidation, { ValidationStates } from '/imports/api/auth-token-validation';
|
2018-09-05 00:56:10 +08:00
|
|
|
|
2022-08-22 20:21:33 +08:00
|
|
|
function presentationUploadToken(podId, filename, temporaryPresentationId) {
|
2020-09-02 00:31:11 +08:00
|
|
|
const tokenValidation = AuthTokenValidation.findOne({ connectionId: this.connection.id });
|
|
|
|
|
|
|
|
if (!tokenValidation || tokenValidation.validationStatus !== ValidationStates.VALIDATED) {
|
|
|
|
Logger.warn(`Publishing PresentationUploadToken was requested by unauth connection ${this.connection.id}`);
|
2020-02-07 04:47:28 +08:00
|
|
|
return PresentationUploadToken.find({ meetingId: '' });
|
|
|
|
}
|
2020-09-02 00:31:11 +08:00
|
|
|
|
|
|
|
const { meetingId, userId } = tokenValidation;
|
|
|
|
|
2018-09-05 00:56:10 +08:00
|
|
|
check(podId, 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,
|
2020-09-02 00:31:11 +08:00
|
|
|
userId,
|
2018-09-05 00:56:10 +08:00
|
|
|
filename,
|
2022-08-22 20:21:33 +08:00
|
|
|
temporaryPresentationId,
|
2018-09-05 00:56:10 +08:00
|
|
|
};
|
|
|
|
|
2020-11-24 23:13:09 +08:00
|
|
|
Logger.debug('Publishing PresentationUploadToken', { meetingId, userId });
|
2018-09-05 00:56:10 +08:00
|
|
|
|
|
|
|
return PresentationUploadToken.find(selector);
|
2020-02-08 06:11:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function publish(...args) {
|
|
|
|
const boundPresentationUploadToken = presentationUploadToken.bind(this);
|
|
|
|
return boundPresentationUploadToken(...args);
|
|
|
|
}
|
|
|
|
|
|
|
|
Meteor.publish('presentation-upload-token', publish);
|