bigbluebutton-Github/bigbluebutton-html5/imports/api/annotations/server/handlers/whiteboardAnnotations.js

31 lines
1.0 KiB
JavaScript
Raw Normal View History

2016-11-19 01:35:28 +08:00
import { check } from 'meteor/check';
2018-04-10 07:18:49 +08:00
import modifyWhiteboardAccess from '/imports/api/whiteboard-multi-user/server/modifiers/modifyWhiteboardAccess';
import clearAnnotations from '../modifiers/clearAnnotations';
import addAnnotation from '../modifiers/addAnnotation';
2016-11-19 01:35:28 +08:00
async function handleWhiteboardAnnotations({ header, body }, meetingId) {
check(header, Object);
if (header.userId !== 'nodeJSapp') { return false; }
2016-11-19 01:35:28 +08:00
check(meetingId, String);
check(body, Object);
2016-11-19 01:35:28 +08:00
2018-04-10 07:18:49 +08:00
const { annotations, whiteboardId, multiUser } = body;
2018-04-10 07:18:49 +08:00
check(annotations, Array);
check(whiteboardId, String);
check(multiUser, Array);
2018-04-10 07:18:49 +08:00
await clearAnnotations(meetingId, whiteboardId);
// we use a for loop here instead of a map because we need to guarantee the order of the annotations.
for (const annotation of annotations) {
const { wbId, userId } = annotation;
await addAnnotation(meetingId, wbId, userId, annotation);
}
await modifyWhiteboardAccess(meetingId, whiteboardId, multiUser);
return true;
2017-06-03 03:25:02 +08:00
}
export default handleWhiteboardAnnotations;