2018-04-06 03:59:26 +08:00
|
|
|
import { Meteor } from 'meteor/meteor';
|
2018-04-10 11:57:24 +08:00
|
|
|
import PresentationPods from '/imports/api/presentation-pods';
|
2018-04-06 03:59:26 +08:00
|
|
|
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-04-06 03:59:26 +08:00
|
|
|
|
2020-02-07 04:47:28 +08:00
|
|
|
function presentationPods() {
|
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 PresentationPods was requested by unauth connection ${this.connection.id}`);
|
2020-02-07 04:47:28 +08:00
|
|
|
return PresentationPods.find({ meetingId: '' });
|
|
|
|
}
|
2020-09-02 00:31:11 +08:00
|
|
|
|
|
|
|
const { meetingId, userId } = tokenValidation;
|
|
|
|
Logger.debug(`Publishing PresentationPods for ${meetingId} ${userId}`);
|
2018-04-06 03:59:26 +08:00
|
|
|
|
|
|
|
return PresentationPods.find({ meetingId });
|
|
|
|
}
|
|
|
|
|
|
|
|
function publish(...args) {
|
|
|
|
const boundPresentationPods = presentationPods.bind(this);
|
2018-11-06 03:30:37 +08:00
|
|
|
return boundPresentationPods(...args);
|
2018-04-06 03:59:26 +08:00
|
|
|
}
|
|
|
|
|
2018-04-10 11:57:24 +08:00
|
|
|
Meteor.publish('presentation-pods', publish);
|