bigbluebutton-Github/bigbluebutton-html5/imports/api/users/server/modifiers/clearUsers.js
2023-03-20 16:35:52 -03:00

27 lines
685 B
JavaScript

import Logger from '/imports/startup/server/logger';
import Users from '/imports/api/users/index';
export default async function clearUsers(meetingId) {
if (meetingId) {
try {
const numberAffected = await Users.removeAsync({ meetingId });
if (numberAffected) {
Logger.info(`Cleared Users (${meetingId})`);
}
} catch (err) {
Logger.error(`Error clearing Users (${meetingId}). ${err}`);
}
} else {
try {
const numberAffected = await Users.removeAsync({});
if (numberAffected) {
Logger.info('Cleared Users (all)');
}
} catch (err) {
Logger.error(`Error clearing Users (all). ${err}`);
}
}
}