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';
|
|
|
|
|
2020-02-07 04:47:28 +08:00
|
|
|
export default function editCaptions(meetingId, userId, padId) { // TODO
|
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';
|
|
|
|
|
|
|
|
check(meetingId, String);
|
|
|
|
check(userId, String);
|
|
|
|
check(padId, String);
|
|
|
|
|
2019-05-29 22:31:27 +08:00
|
|
|
const pad = Captions.findOne({ meetingId, padId });
|
2019-05-22 03:21:46 +08:00
|
|
|
|
2020-12-01 04:01:41 +08:00
|
|
|
if (!pad) {
|
|
|
|
Logger.error(`Editing captions owner: ${padId}`);
|
|
|
|
return;
|
|
|
|
}
|
2019-05-22 03:21:46 +08:00
|
|
|
|
|
|
|
const { locale } = pad;
|
|
|
|
|
|
|
|
check(locale, { locale: String, name: String });
|
|
|
|
|
|
|
|
const payload = {
|
|
|
|
ownerId: userId,
|
|
|
|
locale: locale.name,
|
|
|
|
localeCode: locale.locale,
|
|
|
|
};
|
|
|
|
|
|
|
|
return RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, userId, payload);
|
|
|
|
}
|