2021-10-16 03:07:13 +08:00
|
|
|
import Pads, { PadsSessions, PadsUpdates } from '/imports/api/pads';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
|
2023-03-16 22:00:45 +08:00
|
|
|
const clear = async (meetingId, name, collection) => {
|
2021-10-16 03:07:13 +08:00
|
|
|
if (meetingId) {
|
|
|
|
try {
|
2023-03-16 22:00:45 +08:00
|
|
|
const result = await collection.removeAsync({ meetingId });
|
|
|
|
if (result) {
|
2021-10-16 03:07:13 +08:00
|
|
|
Logger.info(`Cleared ${name} (${meetingId})`);
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Error on clearing ${name} (${meetingId}). ${err}`);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
try {
|
2023-03-16 22:00:45 +08:00
|
|
|
const result = await collection.removeAsync({});
|
|
|
|
if (result) {
|
2021-10-16 03:07:13 +08:00
|
|
|
Logger.info(`Cleared ${name} (all)`);
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Error on clearing ${name} (all). ${err}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-03-16 22:00:45 +08:00
|
|
|
export default async function clearPads(meetingId) {
|
|
|
|
await clear(meetingId, 'Pads', Pads);
|
|
|
|
await clear(meetingId, 'PadsSessions', PadsSessions);
|
|
|
|
await clear(meetingId, 'PadsUpdates', PadsUpdates);
|
2021-10-16 03:07:13 +08:00
|
|
|
}
|