bigbluebutton-Github/bigbluebutton-html5/imports/api/captions/server/methods/updateOwner.js
Pedro Beschorner Marin f7793bdc4b fix(closed captions): avoid padId subscription
Remove padIds from the closed captions MongoDB collection subscription.

Users now have to fetch the padId from Meteor when needed. Meteor is
responsible for checking the user's access level and return the
proper id.
2021-10-04 14:35:53 -03:00

35 lines
994 B
JavaScript

import RedisPubSub from '/imports/startup/server/redis';
import Captions from '/imports/api/captions';
import Logger from '/imports/startup/server/logger';
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
export default function updateOwner(meetingId, userId, locale) {
const REDIS_CONFIG = Meteor.settings.private.redis;
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
const EVENT_NAME = 'UpdateCaptionOwnerPubMsg';
try {
check(meetingId, String);
check(userId, String);
check(locale, String);
const pad = Captions.findOne({ meetingId, locale });
if (!pad) {
Logger.error(`Editing captions owner: ${padId}`);
return;
}
const payload = {
ownerId: userId,
locale: pad.name,
localeCode: pad.locale,
};
RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, userId, payload);
} catch (err) {
Logger.error(`Exception while invoking method updateOwner ${err.stack}`);
}
}