bigbluebutton-Github/bigbluebutton-html5/imports/api/slides/server/modifiers/clearSlidesPresentation.js

31 lines
902 B
JavaScript
Raw Normal View History

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';
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,
};
const whiteboardIds = Slides.find(selector, { fields: { id: 1 } }).map(row => row.id);
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));
2017-10-12 08:59:35 +08:00
return Logger.info(`Removed Slides where presentationId=${presentationId}`);
2016-10-21 19:41:17 +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
}