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
|
|
|
|
2023-03-09 01:35:40 +08:00
|
|
|
export default async function removeGuest(meetingId, intId) {
|
2020-01-15 23:01:28 +08:00
|
|
|
check(meetingId, String);
|
|
|
|
check(intId, String);
|
|
|
|
|
|
|
|
const selector = {
|
|
|
|
meetingId,
|
|
|
|
intId,
|
|
|
|
};
|
|
|
|
|
2023-03-09 01:35:40 +08:00
|
|
|
try {
|
|
|
|
const result = await GuestUsers.removeAsync(selector);
|
|
|
|
if (result) {
|
|
|
|
Logger.info(`Removed guest user id=${intId} meetingId=${meetingId}`);
|
2020-01-15 23:01:28 +08:00
|
|
|
}
|
2023-03-09 01:35:40 +08:00
|
|
|
} catch (err) {
|
|
|
|
return Logger.error(`Removing guest user from collection: ${err}`);
|
|
|
|
}
|
2020-01-15 23:01:28 +08:00
|
|
|
|
2023-03-09 01:35:40 +08:00
|
|
|
// Update position of waiting users after user has left the guest lobby.
|
|
|
|
await updatePositionInWaitingQueue(meetingId);
|
2022-01-12 11:08:43 +08:00
|
|
|
|
2023-03-09 01:35:40 +08:00
|
|
|
return true;
|
2020-01-15 23:01:28 +08:00
|
|
|
}
|