2017-07-03 23:05:35 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
2017-10-23 23:47:14 +08:00
|
|
|
import Users from '/imports/api/users/index';
|
2017-07-03 23:05:35 +08:00
|
|
|
|
2023-03-15 21:18:31 +08:00
|
|
|
export default async function clearUsers(meetingId) {
|
2017-07-03 23:05:35 +08:00
|
|
|
if (meetingId) {
|
2020-11-25 04:44:13 +08:00
|
|
|
try {
|
2023-03-15 21:18:31 +08:00
|
|
|
const numberAffected = await Users.removeAsync({ meetingId });
|
2017-07-03 23:05:35 +08:00
|
|
|
|
2020-11-25 04:44:13 +08:00
|
|
|
if (numberAffected) {
|
|
|
|
Logger.info(`Cleared Users (${meetingId})`);
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Error clearing Users (${meetingId}). ${err}`);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
try {
|
2023-03-15 21:18:31 +08:00
|
|
|
const numberAffected = await Users.removeAsync({});
|
2017-10-06 20:50:01 +08:00
|
|
|
|
2020-11-25 04:44:13 +08:00
|
|
|
if (numberAffected) {
|
|
|
|
Logger.info('Cleared Users (all)');
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Error clearing Users (all). ${err}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|