bigbluebutton-Github/bigbluebutton-html5/imports/api/captions/server/methods/updateOwner.js

35 lines
994 B
JavaScript
Raw Normal View History

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';
2021-05-05 01:34:31 +08:00
try {
check(meetingId, String);
check(userId, String);
check(locale, String);
const pad = Captions.findOne({ meetingId, locale });
2021-05-05 01:34:31 +08:00
if (!pad) {
Logger.error(`Editing captions owner: ${padId}`);
return;
}
2021-05-05 01:34:31 +08:00
const payload = {
ownerId: userId,
locale: pad.name,
localeCode: pad.locale,
2021-05-05 01:34:31 +08:00
};
2021-05-05 01:34:31 +08:00
RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, userId, payload);
} catch (err) {
Logger.error(`Exception while invoking method updateOwner ${err.stack}`);
}
}