2018-11-30 01:24:02 +08:00
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
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
|
|
|
|
2021-05-28 07:50:43 +08:00
|
|
|
export default function startWatchingExternalVideo(externalVideoUrl) {
|
2019-01-16 21:14:32 +08:00
|
|
|
const REDIS_CONFIG = Meteor.settings.private.redis;
|
|
|
|
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
|
2020-08-28 18:58:55 +08:00
|
|
|
const EVENT_NAME = 'StartExternalVideoPubMsg';
|
2019-01-16 21:14:32 +08:00
|
|
|
|
2021-05-28 07:50:43 +08:00
|
|
|
const { meetingId, requesterUserId } = extractCredentials(this.userId);
|
2018-11-30 01:24:02 +08:00
|
|
|
|
2020-09-04 03:07:54 +08:00
|
|
|
try {
|
|
|
|
check(meetingId, String);
|
2021-05-28 07:50:43 +08:00
|
|
|
check(requesterUserId, String);
|
2020-09-04 03:07:54 +08:00
|
|
|
check(externalVideoUrl, String);
|
2018-11-30 01:24:02 +08:00
|
|
|
|
2021-05-27 21:59:14 +08:00
|
|
|
const payload = { externalVideoUrl };
|
2020-09-05 00:49:01 +08:00
|
|
|
|
2021-05-28 07:50:43 +08:00
|
|
|
Logger.info(`User ${requesterUserId} sharing an external video ${externalVideoUrl} for meeting ${meetingId}`);
|
2021-05-27 21:59:14 +08:00
|
|
|
|
2021-05-28 07:50:43 +08:00
|
|
|
return RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
|
2020-09-04 03:07:54 +08:00
|
|
|
} catch (error) {
|
2021-05-28 07:50:43 +08:00
|
|
|
Logger.error(`Error on sharing an external video for meeting ${meetingId}: ${error}`);
|
2020-09-04 03:07:54 +08:00
|
|
|
}
|
2018-11-30 01:24:02 +08:00
|
|
|
}
|