2017-10-12 08:52:57 +08:00
|
|
|
import _ from 'lodash';
|
2016-11-19 01:35:28 +08:00
|
|
|
import { check } from 'meteor/check';
|
2017-10-12 08:52:57 +08:00
|
|
|
import clearAnnotations from '../modifiers/clearAnnotations';
|
|
|
|
import addAnnotation from '../modifiers/addAnnotation';
|
2016-11-19 01:35:28 +08:00
|
|
|
|
2017-10-12 08:52:57 +08:00
|
|
|
export default function handleWhiteboardAnnotations({ body }, meetingId) {
|
2016-11-19 01:35:28 +08:00
|
|
|
check(meetingId, String);
|
2017-10-12 08:52:57 +08:00
|
|
|
check(body, Object);
|
2016-11-19 01:35:28 +08:00
|
|
|
|
2017-10-12 08:52:57 +08:00
|
|
|
const { annotations, whiteboardId } = body;
|
2017-02-24 21:10:55 +08:00
|
|
|
|
2017-10-12 08:52:57 +08:00
|
|
|
check(whiteboardId, String);
|
|
|
|
clearAnnotations(meetingId, whiteboardId);
|
2017-02-24 21:10:55 +08:00
|
|
|
|
2017-10-12 08:52:57 +08:00
|
|
|
const annotationsAdded = [];
|
|
|
|
_.each(annotations, (annotation) => {
|
|
|
|
const { wbId, userId } = annotation;
|
|
|
|
annotationsAdded.push(addAnnotation(meetingId, wbId, userId, annotation));
|
2016-11-19 01:35:28 +08:00
|
|
|
});
|
2017-10-12 08:52:57 +08:00
|
|
|
|
|
|
|
return annotationsAdded;
|
2017-06-03 03:25:02 +08:00
|
|
|
}
|