bigbluebutton-Github/bigbluebutton-html5/imports/api/captions/server/publishers.js
2023-03-20 16:23:41 -03:00

27 lines
923 B
JavaScript

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