2021-02-10 23:24:24 +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';
|
|
|
|
|
|
|
|
export default function addPad(padId, readOnlyId) {
|
|
|
|
const REDIS_CONFIG = Meteor.settings.private.redis;
|
|
|
|
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
|
|
|
|
const EVENT_NAME = 'AddPadSysMsg';
|
|
|
|
|
2021-05-05 01:34:31 +08:00
|
|
|
try {
|
|
|
|
check(padId, String);
|
|
|
|
check(readOnlyId, String);
|
2021-02-10 23:24:24 +08:00
|
|
|
|
2021-05-05 01:34:31 +08:00
|
|
|
const pad = Captions.findOne({ padId });
|
2021-02-10 23:24:24 +08:00
|
|
|
|
2021-05-05 01:34:31 +08:00
|
|
|
if (!pad) {
|
|
|
|
Logger.error(`Could not find closed captions pad ${padId}`);
|
|
|
|
return;
|
|
|
|
}
|
2021-02-10 23:24:24 +08:00
|
|
|
|
2021-05-05 01:34:31 +08:00
|
|
|
const { meetingId } = pad;
|
2021-02-10 23:24:24 +08:00
|
|
|
|
2021-05-05 01:34:31 +08:00
|
|
|
check(meetingId, String);
|
2021-02-10 23:24:24 +08:00
|
|
|
|
2021-05-05 01:34:31 +08:00
|
|
|
const payload = {
|
|
|
|
padId,
|
|
|
|
readOnlyId,
|
|
|
|
};
|
2021-02-10 23:24:24 +08:00
|
|
|
|
2021-05-05 01:34:31 +08:00
|
|
|
RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, 'nodeJSapp', payload);
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Exception while invoking method addPad ${err.stack}`);
|
|
|
|
}
|
2021-02-10 23:24:24 +08:00
|
|
|
}
|