bigbluebutton-Github/bigbluebutton-html5/imports/api/users/server/methods/userLeaving.js
Anton Georgiev 97682d9162 Revert "Merge pull request #8759 from capilkey/2.2-join-fix"
This reverts commit 5af41dabb4, reversing
changes made to 004d872584.
2020-03-25 16:12:36 -04:00

38 lines
1.0 KiB
JavaScript
Executable File

import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import RedisPubSub from '/imports/startup/server/redis';
import Logger from '/imports/startup/server/logger';
import Users from '/imports/api/users';
export default function userLeaving(meetingId, userId, connectionId) {
const REDIS_CONFIG = Meteor.settings.private.redis;
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
const EVENT_NAME = 'UserLeaveReqMsg';
check(userId, String);
const selector = {
meetingId,
userId,
};
const User = Users.findOne(selector);
if (!User) {
return Logger.info(`Skipping userLeaving. Could not find ${userId} in ${meetingId}`);
}
// If the current user connection is not the same that triggered the leave we skip
if (User.connectionId !== connectionId) {
return false;
}
const payload = {
userId,
sessionId: meetingId,
};
Logger.info(`User '${userId}' is leaving meeting '${meetingId}'`);
return RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, userId, payload);
}