2020-08-29 01:23:27 +08:00
|
|
|
import Meetings from '/imports/api/meetings';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
import { check } from 'meteor/check';
|
|
|
|
|
|
|
|
export default function updateRandomUser(meetingId, userId, requesterId) {
|
|
|
|
check(meetingId, String);
|
|
|
|
check(userId, String);
|
|
|
|
check(requesterId, String);
|
|
|
|
|
|
|
|
const selector = {
|
|
|
|
meetingId,
|
|
|
|
};
|
|
|
|
|
|
|
|
const modifier = {
|
|
|
|
$set: {
|
|
|
|
randomlySelectedUser: userId,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-01-19 09:53:13 +08:00
|
|
|
try {
|
|
|
|
const { insertedId } = Meetings.upsert(selector, modifier);
|
|
|
|
if (insertedId) {
|
|
|
|
Logger.info(`Set randomly selected userId=${userId} by requesterId=${requesterId} in meeitingId=${meetingId}`);
|
2020-08-29 01:23:27 +08:00
|
|
|
}
|
2021-01-19 09:53:13 +08:00
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Setting randomly selected userId=${userId} by requesterId=${requesterId} in meetingId=${meetingId}`);
|
|
|
|
}
|
2020-08-29 01:23:27 +08:00
|
|
|
}
|