2018-11-30 01:24:02 +08:00
|
|
|
import { Meteor } from 'meteor/meteor';
|
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
import Meetings from '/imports/api/meetings';
|
2019-01-16 21:14:32 +08:00
|
|
|
import RedisPubSub from '/imports/startup/server/redis';
|
2020-02-07 04:47:28 +08:00
|
|
|
import { extractCredentials } from '/imports/api/common/server/helpers';
|
2018-11-30 01:24:02 +08:00
|
|
|
|
2020-02-07 04:47:28 +08:00
|
|
|
export default function startWatchingExternalVideo(options) {
|
2019-01-16 21:14:32 +08:00
|
|
|
const REDIS_CONFIG = Meteor.settings.private.redis;
|
|
|
|
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
|
|
|
|
const EVENT_NAME = 'StartExternalVideoMsg';
|
|
|
|
|
2020-02-07 04:47:28 +08:00
|
|
|
const { meetingId, requesterUserId } = extractCredentials(this.userId);
|
2018-11-30 01:24:02 +08:00
|
|
|
const { externalVideoUrl } = options;
|
|
|
|
|
|
|
|
check(externalVideoUrl, String);
|
|
|
|
|
2019-01-16 21:14:32 +08:00
|
|
|
Meetings.update({ meetingId }, { $set: { externalVideoUrl } });
|
|
|
|
|
|
|
|
const payload = { externalVideoUrl };
|
|
|
|
|
2019-08-27 04:39:20 +08:00
|
|
|
Logger.info(`User id=${requesterUserId} sharing an external video: ${externalVideoUrl} for meeting ${meetingId}`);
|
2019-02-19 20:19:13 +08:00
|
|
|
|
2019-01-16 21:14:32 +08:00
|
|
|
return RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
|
2018-11-30 01:24:02 +08:00
|
|
|
}
|