import { Meteor } from 'meteor/meteor'; import Presentations from '/imports/api/presentations'; import Logger from '/imports/startup/server/logger'; import AuthTokenValidation, { ValidationStates } from '/imports/api/auth-token-validation'; function presentations() { const tokenValidation = AuthTokenValidation.findOne({ connectionId: this.connection.id }); if (!tokenValidation || tokenValidation.validationStatus !== ValidationStates.VALIDATED) { Logger.warn(`Publishing Presentation was requested by unauth connection ${this.connection.id}`); return Presentations.find({ meetingId: '' }); } const { meetingId, userId } = tokenValidation; Logger.debug('Publishing Presentations', { meetingId, userId }); return Presentations.find({ meetingId }); } function publish(...args) { const boundPresentations = presentations.bind(this); return boundPresentations(...args); } Meteor.publish('presentations', publish);