bigbluebutton-Github/bigbluebutton-html5/imports/api/local-settings/server/publishers.js

28 lines
966 B
JavaScript
Raw Normal View History

import { Meteor } from 'meteor/meteor';
import LocalSettings from '/imports/api/local-settings';
import Logger from '/imports/startup/server/logger';
import AuthTokenValidation, { ValidationStates } from '/imports/api/auth-token-validation';
async function localSettings() {
const tokenValidation = await AuthTokenValidation
.findOneAsync({ connectionId: this.connection.id });
if (!tokenValidation || tokenValidation.validationStatus !== ValidationStates.VALIDATED) {
Logger.warn(`Publishing LocalSettings was requested by unauth connection ${this.connection.id}`);
return LocalSettings.find({ meetingId: '' });
}
const { meetingId, userId } = tokenValidation;
2020-11-24 23:13:09 +08:00
Logger.debug('Publishing local settings', { userId });
return LocalSettings.find({ meetingId, userId });
}
function publish(...args) {
const boundLocalSettings = localSettings.bind(this);
return boundLocalSettings(...args);
}
Meteor.publish('local-settings', publish);