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

36 lines
759 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';
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
},
};
const cb = (err, numChanged) => {
if (err) {
2017-09-29 01:41:02 +08:00
return Logger.error(`Ejecting user from collection: ${err}`);
2017-09-22 00:21:42 +08:00
}
if (numChanged) {
return Logger.info(`Ejected user id=${userId} meeting=${meetingId} reason=${ejectedReason}`);
2017-09-22 00:21:42 +08:00
}
return null;
};
2017-10-04 23:45:05 +08:00
return Users.update(selector, modifier, cb);
2017-09-22 00:21:42 +08:00
}