2017-09-22 00:21:42 +08:00
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
2017-09-22 01:40:19 +08:00
|
|
|
import Users from '/imports/api/2.0/users';
|
2017-09-22 00:21:42 +08:00
|
|
|
|
2017-09-28 05:20:22 +08:00
|
|
|
export default function userEjected(meetingId, userId) {
|
2017-09-22 00:21:42 +08:00
|
|
|
check(meetingId, String);
|
|
|
|
check(userId, String);
|
|
|
|
|
|
|
|
const selector = {
|
|
|
|
meetingId,
|
|
|
|
userId,
|
|
|
|
};
|
|
|
|
|
|
|
|
const modifier = {
|
|
|
|
$set: {
|
2017-09-28 05:20:22 +08:00
|
|
|
ejected: true,
|
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) {
|
2017-09-29 01:41:02 +08:00
|
|
|
return Logger.info(`Ejected user id=${userId} meeting=${meetingId}`);
|
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
|
|
|
}
|