2019-05-22 03:21:46 +08:00
|
|
|
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';
|
|
|
|
|
2021-10-05 03:22:18 +08:00
|
|
|
export default function updateOwner(meetingId, userId, locale) {
|
2019-05-22 03:21:46 +08:00
|
|
|
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);
|
2021-10-05 03:22:18 +08:00
|
|
|
check(locale, String);
|
2019-05-22 03:21:46 +08:00
|
|
|
|
2021-10-05 03:22:18 +08:00
|
|
|
const pad = Captions.findOne({ meetingId, locale });
|
2019-05-22 03:21:46 +08:00
|
|
|
|
2021-05-05 01:34:31 +08:00
|
|
|
if (!pad) {
|
|
|
|
Logger.error(`Editing captions owner: ${padId}`);
|
|
|
|
return;
|
|
|
|
}
|
2019-05-22 03:21:46 +08:00
|
|
|
|
2021-05-05 01:34:31 +08:00
|
|
|
const payload = {
|
|
|
|
ownerId: userId,
|
2021-10-05 03:22:18 +08:00
|
|
|
locale: pad.name,
|
|
|
|
localeCode: pad.locale,
|
2021-05-05 01:34:31 +08:00
|
|
|
};
|
2019-05-22 03:21:46 +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}`);
|
|
|
|
}
|
2019-05-22 03:21:46 +08:00
|
|
|
}
|