Remove callbacks from update and clear Mongo operations for randomly selecting a user
This commit is contained in:
parent
88c6e773e3
commit
5238dac647
@ -9,18 +9,18 @@ export default function clearRandomlySelectedUser() {
|
||||
meetingId,
|
||||
};
|
||||
|
||||
const cb = (err) => {
|
||||
if (err) return Logger.error(`Clearing randomly selected user : ${err}`);
|
||||
Logger.info(`Cleared randomly selected user from meeting=${meetingId} by id=${requesterUserId}`);
|
||||
const modifier = {
|
||||
$set: {
|
||||
randomlySelectedUser: '',
|
||||
},
|
||||
};
|
||||
|
||||
return Meetings.update(
|
||||
selector,
|
||||
{
|
||||
$set: {
|
||||
randomlySelectedUser: '',
|
||||
},
|
||||
},
|
||||
cb,
|
||||
);
|
||||
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}`);
|
||||
}
|
||||
}
|
||||
|
@ -17,13 +17,12 @@ export default function updateRandomUser(meetingId, userId, requesterId) {
|
||||
},
|
||||
};
|
||||
|
||||
const cb = (err) => {
|
||||
if (err != null) {
|
||||
return Logger.error(`Setting randomly selected userId=${userId} by requesterId=${requesterId} in meetingId=${meetingId}`);
|
||||
try {
|
||||
const { insertedId } = Meetings.upsert(selector, modifier);
|
||||
if (insertedId) {
|
||||
Logger.info(`Set randomly selected userId=${userId} by requesterId=${requesterId} in meeitingId=${meetingId}`);
|
||||
}
|
||||
|
||||
return Logger.info(`Set randomly selected userId=${userId} by requesterId=${requesterId} in meeitingId=${meetingId}`);
|
||||
};
|
||||
|
||||
return Meetings.upsert(selector, modifier, cb);
|
||||
} catch (err) {
|
||||
Logger.error(`Setting randomly selected userId=${userId} by requesterId=${requesterId} in meetingId=${meetingId}`);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user