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';
|
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
|
|
|
|
2023-03-08 21:32:24 +08:00
|
|
|
async function handleWhiteboardAnnotations({ header, body }, meetingId) {
|
2018-04-11 07:49:56 +08:00
|
|
|
check(header, Object);
|
|
|
|
if (header.userId !== 'nodeJSapp') { return false; }
|
|
|
|
|
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
|
|
|
|
2018-04-10 07:18:49 +08:00
|
|
|
const { annotations, whiteboardId, multiUser } = body;
|
2017-02-24 21:10:55 +08:00
|
|
|
|
2018-04-10 07:18:49 +08:00
|
|
|
check(annotations, Array);
|
2017-10-12 08:52:57 +08:00
|
|
|
check(whiteboardId, String);
|
2021-03-05 06:26:25 +08:00
|
|
|
check(multiUser, Array);
|
2018-04-10 07:18:49 +08:00
|
|
|
|
2023-03-08 21:32:24 +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) {
|
2017-10-12 08:52:57 +08:00
|
|
|
const { wbId, userId } = annotation;
|
2023-03-08 21:32:24 +08:00
|
|
|
await addAnnotation(meetingId, wbId, userId, annotation);
|
|
|
|
}
|
2017-10-12 08:52:57 +08:00
|
|
|
|
2018-04-10 07:18:49 +08:00
|
|
|
modifyWhiteboardAccess(meetingId, whiteboardId, multiUser);
|
2017-06-03 03:25:02 +08:00
|
|
|
}
|
2023-03-08 21:32:24 +08:00
|
|
|
|
|
|
|
export default handleWhiteboardAnnotations;
|