2019-08-01 03:10:41 +08:00
|
|
|
import { Slides, SlidePositions } from '/imports/api/slides';
|
2016-10-21 19:41:17 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
import { check } from 'meteor/check';
|
2017-10-12 10:00:28 +08:00
|
|
|
import clearAnnotations from '/imports/api/annotations/server/modifiers/clearAnnotations';
|
2016-10-21 19:41:17 +08:00
|
|
|
|
2023-04-01 04:40:41 +08:00
|
|
|
export default async function clearSlidesPresentation(meetingId, presentationId) {
|
2016-11-12 03:02:46 +08:00
|
|
|
check(meetingId, String);
|
2016-10-21 19:41:17 +08:00
|
|
|
check(presentationId, String);
|
|
|
|
|
|
|
|
const selector = {
|
2016-11-12 03:02:46 +08:00
|
|
|
meetingId,
|
2016-10-21 19:41:17 +08:00
|
|
|
presentationId,
|
|
|
|
};
|
|
|
|
|
2023-04-01 04:40:41 +08:00
|
|
|
const whiteboardIds = await Slides.find(selector, { fields: { id: 1 } }).mapAsync(row => row.id);
|
2016-11-22 00:04:42 +08:00
|
|
|
|
2020-11-25 04:44:13 +08:00
|
|
|
try {
|
2023-04-01 04:40:41 +08:00
|
|
|
await SlidePositions.removeAsync(selector);
|
2016-11-22 00:04:42 +08:00
|
|
|
|
2023-04-01 04:40:41 +08:00
|
|
|
const numberAffected = await Slides.removeAsync(selector);
|
2016-10-21 19:41:17 +08:00
|
|
|
|
2020-11-25 04:44:13 +08:00
|
|
|
if (numberAffected) {
|
2023-04-01 04:40:41 +08:00
|
|
|
whiteboardIds.forEach(async (whiteboardId) => clearAnnotations(meetingId, whiteboardId));
|
2019-08-01 03:10:41 +08:00
|
|
|
|
2020-11-25 04:44:13 +08:00
|
|
|
Logger.info(`Removed Slides where presentationId=${presentationId}`);
|
|
|
|
}
|
|
|
|
} catch (err) {
|
2020-12-01 04:01:41 +08:00
|
|
|
Logger.error(`Removing Slides from collection: ${err}`);
|
2020-11-25 04:44:13 +08:00
|
|
|
}
|
2017-06-03 03:25:02 +08:00
|
|
|
}
|