bigbluebutton-Github/bigbluebutton-html5/imports/api/users/server/modifiers/userEjected.js

34 lines
871 B
JavaScript
Raw Normal View History

2017-09-22 00:21:42 +08:00
import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
import Users from '/imports/api/users';
import clearUserInfoForRequester from '/imports/api/users-infos/server/modifiers/clearUserInfoForRequester';
2017-09-22 00:21:42 +08:00
export default function userEjected(meetingId, userId, ejectedReason) {
2017-09-22 00:21:42 +08:00
check(meetingId, String);
check(userId, String);
check(ejectedReason, String);
2017-09-22 00:21:42 +08:00
const selector = {
meetingId,
userId,
};
const modifier = {
$set: {
ejected: true,
ejectedReason,
2017-09-22 00:21:42 +08:00
},
};
try {
const numberAffected = Users.update(selector, modifier);
2017-09-22 00:21:42 +08:00
if (numberAffected) {
clearUserInfoForRequester(meetingId, userId);
Logger.info(`Ejected user id=${userId} meeting=${meetingId} reason=${ejectedReason}`);
2017-09-22 00:21:42 +08:00
}
} catch (err) {
Logger.error(`Ejecting user from collection: ${err}`);
}
2017-09-22 00:21:42 +08:00
}