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
|
|
|
|
2020-02-08 06:11:06 +08:00
|
|
|
function presentationUploadToken(podId, filename) {
|
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);
|
|
|
|
|
|
|
|
const selector = {
|
|
|
|
meetingId,
|
|
|
|
podId,
|
2020-09-02 00:31:11 +08:00
|
|
|
userId,
|
2018-09-05 00:56:10 +08:00
|
|
|
filename,
|
|
|
|
};
|
|
|
|
|
2020-09-02 00:31:11 +08:00
|
|
|
Logger.debug(`Publishing PresentationUploadToken for ${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);
|