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;
|
|
|
|
|
2020-09-04 03:07:54 +08:00
|
|
|
try {
|
|
|
|
check(meetingId, String);
|
|
|
|
check(requesterUserId, String);
|
|
|
|
check(externalVideoUrl, String);
|
2018-11-30 01:24:02 +08:00
|
|
|
|
2020-09-04 03:07:54 +08:00
|
|
|
Meetings.update({ meetingId }, { $set: { externalVideoUrl } });
|
2019-01-16 21:14:32 +08:00
|
|
|
|
2020-09-04 03:07:54 +08:00
|
|
|
const payload = { externalVideoUrl };
|
2019-01-16 21:14:32 +08:00
|
|
|
|
2020-09-04 03:07:54 +08:00
|
|
|
Logger.info(`User id=${requesterUserId} sharing an external video: ${externalVideoUrl} for meeting ${meetingId}`);
|
2019-02-19 20:19:13 +08:00
|
|
|
|
2020-09-04 03:07:54 +08:00
|
|
|
return RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
|
|
|
|
} catch (error) {
|
|
|
|
Logger.error(`Error on sharing an external video: ${externalVideoUrl} ${error}`);
|
|
|
|
}
|
2018-11-30 01:24:02 +08:00
|
|
|
}
|