2017-10-12 10:00:28 +08:00
|
|
|
import Annotations from '/imports/api/annotations';
|
2016-11-19 01:35:28 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
|
2017-10-12 08:52:57 +08:00
|
|
|
export default function clearAnnotations(meetingId, whiteboardId, userId) {
|
|
|
|
const selector = {};
|
|
|
|
|
2016-11-19 01:35:28 +08:00
|
|
|
if (meetingId) {
|
2017-10-12 08:52:57 +08:00
|
|
|
selector.meetingId = meetingId;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (whiteboardId) {
|
|
|
|
selector.whiteboardId = whiteboardId;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (userId) {
|
|
|
|
selector.userId = userId;
|
2016-11-19 01:35:28 +08:00
|
|
|
}
|
|
|
|
|
2017-10-12 08:52:57 +08:00
|
|
|
const cb = (err) => {
|
|
|
|
if (err) {
|
|
|
|
return Logger.error(`Removing Shapes2x from collection: ${err}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!meetingId) {
|
|
|
|
return Logger.info('Cleared Annotations (all)');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (userId) {
|
|
|
|
return Logger.info(`Removed Shapes2x for userId=${userId} where whiteboard=${whiteboardId}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Logger.info(`Removed Shapes2x where whiteboard=${whiteboardId}`);
|
|
|
|
};
|
|
|
|
|
|
|
|
return Annotations.remove(selector, cb);
|
2017-06-03 03:25:02 +08:00
|
|
|
}
|