52654bc927
Co-authored-by: Anton Georgiev <antobinary@users.noreply.github.com>
31 lines
1.2 KiB
JavaScript
31 lines
1.2 KiB
JavaScript
import { Meteor } from 'meteor/meteor';
|
|
import Logger from '/imports/startup/server/logger';
|
|
import Meetings from '/imports/api/meetings';
|
|
import RedisPubSub from '/imports/startup/server/redis';
|
|
import { extractCredentials } from '/imports/api/common/server/helpers';
|
|
|
|
export default function stopWatchingExternalVideo(options) {
|
|
const REDIS_CONFIG = Meteor.settings.private.redis;
|
|
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
|
|
const EVENT_NAME = 'StopExternalVideoMsg';
|
|
|
|
const { meetingId, requesterUserId } = this.userId ? extractCredentials(this.userId) : options;
|
|
|
|
try {
|
|
check(meetingId, String);
|
|
check(requesterUserId, String);
|
|
|
|
const meeting = Meetings.findOne({ meetingId });
|
|
if (!meeting || meeting.externalVideoUrl === null) return;
|
|
|
|
Meetings.update({ meetingId }, { $set: { externalVideoUrl: null } });
|
|
const payload = {};
|
|
|
|
Logger.info(`User id=${requesterUserId} stopped sharing an external video for meeting=${meetingId}`);
|
|
|
|
RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
|
|
} catch (error) {
|
|
Logger.error(`Error on stop sharing an external video for meeting=${meetingId} ${error}`);
|
|
}
|
|
}
|