2019-05-18 03:39:05 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
import Users from '/imports/api/users';
|
2020-02-07 04:47:28 +08:00
|
|
|
import { extractCredentials } from '/imports/api/common/server/helpers';
|
2019-05-18 03:39:05 +08:00
|
|
|
|
2020-02-07 04:47:28 +08:00
|
|
|
export default function userLeftMeeting() { // TODO-- spread the code to method/modifier/handler
|
|
|
|
// so we don't update the db in a method
|
|
|
|
const { meetingId, requesterUserId } = extractCredentials(this.userId);
|
2019-05-18 03:39:05 +08:00
|
|
|
|
|
|
|
const selector = {
|
|
|
|
meetingId,
|
|
|
|
userId: requesterUserId,
|
|
|
|
};
|
|
|
|
|
2020-11-23 21:13:46 +08:00
|
|
|
try {
|
|
|
|
const numberAffected = Users.update(selector, { $set: { loggedOut: true } });
|
|
|
|
|
|
|
|
if (numberAffected) {
|
2019-05-18 03:39:05 +08:00
|
|
|
Logger.info(`user left id=${requesterUserId} meeting=${meetingId}`);
|
|
|
|
}
|
2020-11-23 21:13:46 +08:00
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`leaving dummy user to collection: ${err}`);
|
|
|
|
}
|
2019-05-18 03:39:05 +08:00
|
|
|
}
|