2018-09-20 01:48:15 +08:00
|
|
|
import PresentationPods from '/imports/api/presentation-pods';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
import clearPresentations from '/imports/api/presentations/server/modifiers/clearPresentations';
|
|
|
|
import clearPresentationUploadToken from '/imports/api/presentation-upload-token/server/modifiers/clearPresentationUploadToken';
|
|
|
|
|
2023-03-15 03:50:35 +08:00
|
|
|
export default async function clearPresentationPods(meetingId) {
|
2018-09-20 01:48:15 +08:00
|
|
|
if (meetingId) {
|
2020-11-25 04:44:13 +08:00
|
|
|
try {
|
2023-03-15 03:50:35 +08:00
|
|
|
const numberAffected = await PresentationPods.removeAsync({ meetingId });
|
2020-11-25 04:44:13 +08:00
|
|
|
|
|
|
|
if (numberAffected) {
|
2023-03-15 03:50:35 +08:00
|
|
|
await clearPresentations(meetingId);
|
|
|
|
await clearPresentationUploadToken(meetingId);
|
2018-09-20 01:48:15 +08:00
|
|
|
Logger.info(`Cleared Presentations Pods (${meetingId})`);
|
2020-11-25 04:44:13 +08:00
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Error on clearing Presentations Pods (${meetingId}). ${err}`);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
try {
|
2023-03-15 03:50:35 +08:00
|
|
|
const numberAffected = await PresentationPods.removeAsync({});
|
2018-09-20 01:48:15 +08:00
|
|
|
|
2020-11-25 04:44:13 +08:00
|
|
|
if (numberAffected) {
|
2023-03-15 03:50:35 +08:00
|
|
|
await clearPresentations();
|
|
|
|
await clearPresentationUploadToken();
|
2020-11-25 04:44:13 +08:00
|
|
|
Logger.info('Cleared Presentations Pods (all)');
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Error on clearing Presentations Pods (all). ${err}`);
|
|
|
|
}
|
|
|
|
}
|
2018-09-20 01:48:15 +08:00
|
|
|
}
|