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
|
|
|
|
2017-10-12 08:59:35 +08:00
|
|
|
const cb = (err) => {
|
2016-10-21 19:41:17 +08:00
|
|
|
if (err) {
|
|
|
|
return Logger.error(`Removing Slides from collection: ${err}`);
|
|
|
|
}
|
|
|
|
|
2017-10-12 08:59:35 +08:00
|
|
|
whiteboardIds.forEach(whiteboardId => clearAnnotations(meetingId, whiteboardId));
|
2016-11-22 00:04:42 +08:00
|
|
|
|
2017-10-12 08:59:35 +08:00
|
|
|
return Logger.info(`Removed Slides where presentationId=${presentationId}`);
|
2016-10-21 19:41:17 +08:00
|
|
|
};
|
|
|
|
|
2019-08-01 03:10:41 +08:00
|
|
|
SlidePositions.remove(selector);
|
|
|
|
|
2016-10-21 19:41:17 +08:00
|
|
|
return Slides.remove(selector, cb);
|
2017-06-03 03:25:02 +08:00
|
|
|
}
|