bigbluebutton-Github/bigbluebutton-html5/imports/api/voice-call-states/server/publishers.js

27 lines
980 B
JavaScript
Raw Normal View History

import VoiceCallStates from '/imports/api/voice-call-states';
import { Meteor } from 'meteor/meteor';
import Logger from '/imports/startup/server/logger';
import AuthTokenValidation, { ValidationStates } from '/imports/api/auth-token-validation';
function voiceCallStates() {
const tokenValidation = AuthTokenValidation.findOne({ connectionId: this.connection.id });
if (!tokenValidation || tokenValidation.validationStatus !== ValidationStates.VALIDATED) {
Logger.warn(`Publishing VoiceCallStates was requested by unauth connection ${this.connection.id}`);
return VoiceCallStates.find({ meetingId: '' });
}
const { meetingId, userId } = tokenValidation;
2020-11-24 23:13:09 +08:00
Logger.debug('Publishing Voice Call States', { meetingId, userId });
return VoiceCallStates.find({ meetingId, userId });
}
function publish(...args) {
const boundVoiceCallStates = voiceCallStates.bind(this);
return boundVoiceCallStates(...args);
}
Meteor.publish('voice-call-states', publish);