Resolve Alex cherry-pick

This commit is contained in:
Oleksandr Zhurbenko 2017-07-27 18:21:02 -07:00 committed by Klaus
parent e23d75c16b
commit 4e31181690
2 changed files with 32 additions and 0 deletions

View File

@ -2,7 +2,9 @@ import RedisPubSub from '/imports/startup/server/redis2x';
import handleWhiteboardCleared from './handlers/whiteboardCleared';
import handleWhiteboardUndo from './handlers/whiteboardUndo';
import handleWhiteboardSend from './handlers/whiteboardSend';
import handleWhiteboardAnnotations from './handlers/whiteboardAnnotations';
RedisPubSub.on('ClearWhiteboardEvtMsg', handleWhiteboardCleared);
RedisPubSub.on('UndoWhiteboardEvtMsg', handleWhiteboardUndo);
RedisPubSub.on('SendWhiteboardAnnotationEvtMsg', handleWhiteboardSend);
RedisPubSub.on('GetWhiteboardAnnotationsRespMsg', handleWhiteboardAnnotations);

View File

@ -0,0 +1,30 @@
import _ from 'lodash';
import { check } from 'meteor/check';
import Annotations from '/imports/api/2.0/annotations';
import addAnnotation from '../modifiers/addAnnotation';
import removeAnnotation from '../modifiers/removeAnnotation';
export default function handleWhiteboardAnnotations({ body }, meetingId) {
check(meetingId, String);
check(body, Object);
const { annotations, whiteboardId } = body;
const annotationIds = annotations.map(annotation => annotation.id);
const annotationsToRemove = Annotations.find({
meetingId,
wbId: whiteboardId,
'annotationInfo.id': { $nin: annotationIds },
}).fetch();
_.each(annotationsToRemove, (annotation) => {
removeAnnotation(meetingId, annotation.whiteboardId, annotation.annotationInfo.id);
});
const annotationsAdded = [];
_.each(annotations, (annotation) => {
const { wbId, userId } = annotation;
annotationsAdded.push(addAnnotation(meetingId, wbId, userId, annotation));
});
return annotationsAdded;
}