2020-10-19 22:46:41 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
import Meetings from '/imports/api/meetings';
|
|
|
|
import { extractCredentials } from '/imports/api/common/server/helpers';
|
2021-03-17 00:15:41 +08:00
|
|
|
import { check } from 'meteor/check';
|
2020-10-19 22:46:41 +08:00
|
|
|
|
2023-03-14 00:59:52 +08:00
|
|
|
export default async function clearRandomlySelectedUser() {
|
2021-05-05 20:58:17 +08:00
|
|
|
try {
|
|
|
|
const { meetingId, requesterUserId } = extractCredentials(this.userId);
|
2020-10-19 22:46:41 +08:00
|
|
|
|
2021-05-05 20:58:17 +08:00
|
|
|
check(meetingId, String);
|
|
|
|
check(requesterUserId, String);
|
2021-03-17 00:15:41 +08:00
|
|
|
|
2021-05-05 20:58:17 +08:00
|
|
|
const selector = {
|
|
|
|
meetingId,
|
|
|
|
};
|
2020-10-19 22:46:41 +08:00
|
|
|
|
2021-05-05 20:58:17 +08:00
|
|
|
const modifier = {
|
|
|
|
$set: {
|
|
|
|
randomlySelectedUser: [],
|
|
|
|
},
|
|
|
|
};
|
2020-10-19 22:46:41 +08:00
|
|
|
|
2023-03-14 00:59:52 +08:00
|
|
|
const numberAffected = await Meetings.updateAsync(selector, modifier);
|
2022-03-01 22:01:21 +08:00
|
|
|
if (numberAffected) {
|
2021-01-19 09:53:13 +08:00
|
|
|
Logger.info(`Cleared randomly selected user from meeting=${meetingId} by id=${requesterUserId}`);
|
|
|
|
}
|
|
|
|
} catch (err) {
|
2021-05-05 20:58:17 +08:00
|
|
|
Logger.error(`Exception while invoking method clearRandomlySelectedUser ${err.stack}`);
|
2021-01-19 09:53:13 +08:00
|
|
|
}
|
2020-10-19 22:46:41 +08:00
|
|
|
}
|