2017-09-22 00:21:42 +08:00
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
2017-10-12 10:00:28 +08:00
|
|
|
import Users from '/imports/api/users';
|
2019-04-06 06:32:21 +08:00
|
|
|
import clearUserInfoForRequester from '/imports/api/users-infos/server/modifiers/clearUserInfoForRequester';
|
2017-09-22 00:21:42 +08:00
|
|
|
|
2023-03-15 21:18:31 +08:00
|
|
|
export default async function userEjected(meetingId, userId, ejectedReason) {
|
2017-09-22 00:21:42 +08:00
|
|
|
check(meetingId, String);
|
|
|
|
check(userId, String);
|
2019-03-13 02:02:52 +08:00
|
|
|
check(ejectedReason, String);
|
2017-09-22 00:21:42 +08:00
|
|
|
|
|
|
|
const selector = {
|
|
|
|
meetingId,
|
|
|
|
userId,
|
|
|
|
};
|
|
|
|
|
|
|
|
const modifier = {
|
|
|
|
$set: {
|
2017-09-28 05:20:22 +08:00
|
|
|
ejected: true,
|
2019-03-13 02:02:52 +08:00
|
|
|
ejectedReason,
|
2017-09-22 00:21:42 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-11-23 21:13:46 +08:00
|
|
|
try {
|
2023-03-15 21:18:31 +08:00
|
|
|
const numberAffected = await Users.updateAsync(selector, modifier);
|
2017-09-22 00:21:42 +08:00
|
|
|
|
2020-11-23 21:13:46 +08:00
|
|
|
if (numberAffected) {
|
2023-03-15 21:18:31 +08:00
|
|
|
await clearUserInfoForRequester(meetingId, userId);
|
2020-11-23 21:13:46 +08:00
|
|
|
Logger.info(`Ejected user id=${userId} meeting=${meetingId} reason=${ejectedReason}`);
|
2017-09-22 00:21:42 +08:00
|
|
|
}
|
2020-11-23 21:13:46 +08:00
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Ejecting user from collection: ${err}`);
|
|
|
|
}
|
2017-09-22 00:21:42 +08:00
|
|
|
}
|