2020-01-15 23:01:28 +08:00
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import GuestUsers from '/imports/api/guest-users';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
2022-01-12 11:08:43 +08:00
|
|
|
import updatePositionInWaitingQueue from '../methods/updatePositionInWaitingQueue';
|
2020-01-15 23:01:28 +08:00
|
|
|
|
|
|
|
export default function removeGuest(meetingId, intId) {
|
|
|
|
check(meetingId, String);
|
|
|
|
check(intId, String);
|
|
|
|
|
|
|
|
const selector = {
|
|
|
|
meetingId,
|
|
|
|
intId,
|
|
|
|
};
|
|
|
|
|
|
|
|
const cb = (err) => {
|
|
|
|
if (err) {
|
|
|
|
return Logger.error(`Removing guest user from collection: ${err}`);
|
|
|
|
}
|
|
|
|
|
2022-01-12 11:08:43 +08:00
|
|
|
/**
|
|
|
|
* Update position of waiting users after user has left the guest lobby
|
|
|
|
*/
|
|
|
|
updatePositionInWaitingQueue(meetingId);
|
|
|
|
|
2020-01-15 23:01:28 +08:00
|
|
|
return Logger.info(`Removed guest user id=${intId} meetingId=${meetingId}`);
|
|
|
|
};
|
|
|
|
|
|
|
|
return GuestUsers.remove(selector, cb);
|
|
|
|
}
|