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
|
|
|
|
|
|
|
export default function clearRandomlySelectedUser() {
|
|
|
|
const { meetingId, requesterUserId } = extractCredentials(this.userId);
|
|
|
|
|
2021-03-17 00:15:41 +08:00
|
|
|
check(meetingId, String);
|
|
|
|
check(requesterUserId, String);
|
|
|
|
|
2020-10-19 22:46:41 +08:00
|
|
|
const selector = {
|
|
|
|
meetingId,
|
|
|
|
};
|
|
|
|
|
2021-01-19 09:53:13 +08:00
|
|
|
const modifier = {
|
|
|
|
$set: {
|
2021-04-15 23:12:10 +08:00
|
|
|
randomlySelectedUser: [],
|
2021-01-19 09:53:13 +08:00
|
|
|
},
|
2020-10-19 22:46:41 +08:00
|
|
|
};
|
|
|
|
|
2021-01-19 09:53:13 +08:00
|
|
|
try {
|
|
|
|
const { insertedId } = Meetings.update(selector, modifier);
|
|
|
|
if (insertedId) {
|
|
|
|
Logger.info(`Cleared randomly selected user from meeting=${meetingId} by id=${requesterUserId}`);
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Clearing randomly selected user : ${err}`);
|
|
|
|
}
|
2020-10-19 22:46:41 +08:00
|
|
|
}
|