bigbluebutton-Github/bigbluebutton-html5/imports/api/audio-captions/server/publishers.js

27 lines
980 B
JavaScript

import AudioCaptions from '/imports/api/audio-captions';
import { Meteor } from 'meteor/meteor';
import Logger from '/imports/startup/server/logger';
import AuthTokenValidation, { ValidationStates } from '/imports/api/auth-token-validation';
async function audioCaptions() {
const tokenValidation = await AuthTokenValidation
.findOneAsync({ connectionId: this.connection.id });
if (!tokenValidation || tokenValidation.validationStatus !== ValidationStates.VALIDATED) {
Logger.warn(`Publishing AudioCaptions was requested by unauth connection ${this.connection.id}`);
return AudioCaptions.find({ meetingId: '' });
}
const { meetingId, userId } = tokenValidation;
Logger.debug('Publishing AudioCaptions', { meetingId, requestedBy: userId });
return AudioCaptions.find({ meetingId });
}
function publish(...args) {
const boundAudioCaptions = audioCaptions.bind(this);
return boundAudioCaptions(...args);
}
Meteor.publish('audio-captions', publish);