Skip to content
Snippets Groups Projects
Commit 3884d45e authored by Tainan Felipe's avatar Tainan Felipe
Browse files

skip userLeaving when meeting is ended

parent e26fe9ee
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@ 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';
import Meetings from '/imports/api/meetings';
export default function userLeaving(credentials, userId, connectionId) {
const REDIS_CONFIG = Meteor.settings.private.redis;
......@@ -15,19 +16,22 @@ export default function userLeaving(credentials, userId, connectionId) {
check(requesterUserId, String);
check(userId, String);
const meeting = Meetings.findOne({ meetingId });
if (!meeting) return false;
const selector = {
meetingId,
userId,
};
const User = Users.findOne(selector);
const user = Users.findOne(selector);
if (!User) {
if (!user) {
throw new Meteor.Error('user-not-found', `Could not find ${userId} in ${meetingId}: cannot complete userLeaving`);
}
// If the current user connection is not the same that triggered the leave we skip
if (User.connectionId !== connectionId) {
if (user.connectionId !== connectionId) {
return false;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment