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
|
|
|
|
2016-11-12 03:02:46 +08:00
|
|
|
export default function clearSlidesPresentation(meetingId, presentationId) {
|
|
|
|
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,
|
|
|
|
};
|
|
|
|
|
2019-08-22 20:05:06 +08:00
|
|
|
const whiteboardIds = Slides.find(selector, { fields: { id: 1 } }).map(row => row.id);
|
2016-11-22 00:04:42 +08:00
|
|
|
|
2020-11-25 04:44:13 +08:00
|
|
|
try {
|
|
|
|
SlidePositions.remove(selector);
|
2016-11-22 00:04:42 +08:00
|
|
|
|
2020-11-25 04:44:13 +08:00
|
|
|
const numberAffected = Slides.remove(selector);
|
2016-10-21 19:41:17 +08:00
|
|
|
|
2020-11-25 04:44:13 +08:00
|
|
|
if (numberAffected) {
|
|
|
|
whiteboardIds.forEach(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
|
|
|
}
|