2022-03-25 03:05:20 +08:00
|
|
|
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';
|
|
|
|
|
2023-03-13 21:11:04 +08:00
|
|
|
async function audioCaptions() {
|
|
|
|
const tokenValidation = await AuthTokenValidation
|
|
|
|
.findOneAsync({ connectionId: this.connection.id });
|
2022-03-25 03:05:20 +08:00
|
|
|
|
|
|
|
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);
|