2017-08-03 03:52:13 +08:00
|
|
|
import Annotations from '/imports/api/2.0/annotations';
|
2017-07-27 20:35:55 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
|
2017-08-17 10:24:59 +08:00
|
|
|
export default function clearAnnotations(meetingId, whiteboardId, userId, fullClear) {
|
|
|
|
const selector = {};
|
|
|
|
|
|
|
|
if (meetingId) {
|
|
|
|
selector.meetingId = meetingId;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (whiteboardId) {
|
|
|
|
selector.whiteboardId = whiteboardId;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!fullClear && userId) {
|
|
|
|
selector.userId = userId;
|
2017-07-27 20:35:55 +08:00
|
|
|
}
|
|
|
|
|
2017-08-17 10:24:59 +08:00
|
|
|
const cb = (err) => {
|
|
|
|
if (err) {
|
|
|
|
return Logger.error(`Removing Shapes2x from collection: ${err}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!meetingId) {
|
|
|
|
return Logger.info('Cleared Annotations (all)');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!fullClear) {
|
|
|
|
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-07-27 20:35:55 +08:00
|
|
|
}
|