bigbluebutton-Github/bigbluebutton-html5/imports/api/users/server/methods/userLeftMeeting.js

33 lines
1.2 KiB
JavaScript
Raw Normal View History

import Logger from '/imports/startup/server/logger';
import Users from '/imports/api/users';
import { extractCredentials } from '/imports/api/common/server/helpers';
import ClientConnections from '/imports/startup/server/ClientConnections';
import { check } from 'meteor/check';
import UsersPersistentData from '/imports/api/users-persistent-data';
export default async function userLeftMeeting() {
// TODO-- spread the code to method/modifier/handler
2021-05-06 00:47:43 +08:00
try {
// so we don't update the db in a method
const { meetingId, requesterUserId } = extractCredentials(this.userId);
2021-05-06 00:47:43 +08:00
check(meetingId, String);
check(requesterUserId, String);
2021-05-06 00:47:43 +08:00
const selector = {
meetingId,
userId: requesterUserId,
};
const numberAffected = await Users.updateAsync(selector, { $set: { loggedOut: true } });
if (numberAffected) {
await UsersPersistentData.updateAsync(selector, { $set: { loggedOut: true } });
Logger.info(`user left id=${requesterUserId} meeting=${meetingId}`);
ClientConnections.removeClientConnection(this.userId, this.connection.id);
}
} catch (err) {
2021-05-06 00:47:43 +08:00
Logger.error(`Exception while invoking method userLeftMeeting ${err.stack}`);
}
}