2017-10-12 10:00:28 +08:00
|
|
|
import Presentations from '/imports/api/presentations';
|
2016-11-12 03:02:46 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
|
2023-03-15 01:27:52 +08:00
|
|
|
export default async function clearPresentations(meetingId, podId) {
|
2018-04-06 04:56:41 +08:00
|
|
|
// clearing presentations for 1 pod
|
|
|
|
if (meetingId && podId) {
|
2020-11-25 04:44:13 +08:00
|
|
|
try {
|
2023-03-15 01:27:52 +08:00
|
|
|
const numberAffected = await Presentations.removeAsync({ meetingId, podId });
|
2020-11-25 04:44:13 +08:00
|
|
|
|
|
|
|
if (numberAffected) {
|
|
|
|
Logger.info(`Cleared Presentations (${meetingId}, ${podId})`);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Error on cleaning Presentations (${meetingId}, ${podId}). ${err}`);
|
|
|
|
return false;
|
|
|
|
}
|
2018-12-15 04:19:10 +08:00
|
|
|
}
|
2018-04-06 04:56:41 +08:00
|
|
|
|
|
|
|
// clearing presentations for the whole meeting
|
2018-12-15 04:19:10 +08:00
|
|
|
if (meetingId) {
|
2020-11-25 04:44:13 +08:00
|
|
|
try {
|
2023-03-15 01:27:52 +08:00
|
|
|
const numberAffected = await Presentations.removeAsync({ meetingId });
|
2018-04-06 04:56:41 +08:00
|
|
|
|
2020-11-25 04:44:13 +08:00
|
|
|
if (numberAffected) {
|
|
|
|
Logger.info(`Cleared Presentations (${meetingId})`);
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Error on cleaning Presentations (${meetingId}). ${err}`);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
try {
|
2023-03-15 01:27:52 +08:00
|
|
|
const numberAffected = await Presentations.removeAsync({});
|
2020-11-25 04:44:13 +08:00
|
|
|
|
|
|
|
if (numberAffected) {
|
|
|
|
Logger.info('Cleared Presentations (all)');
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Error on cleaning Presentations (all). ${err}`);
|
|
|
|
}
|
|
|
|
}
|
2023-03-15 01:27:52 +08:00
|
|
|
// Returned true because the function requires some value to be returned.
|
|
|
|
return true;
|
2017-06-03 03:25:02 +08:00
|
|
|
}
|