bigbluebutton-Github/bigbluebutton-html5/imports/api/guest-users/server/publishers.js

27 lines
908 B
JavaScript

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