bigbluebutton-Github/bigbluebutton-html5/imports/api/annotations/addAnnotation.js

39 lines
777 B
JavaScript
Raw Normal View History

import { check } from 'meteor/check';
2023-03-01 22:52:39 +08:00
import { defaultsDeep } from '/imports/utils/array-utils';
async function addAnnotation(meetingId, whiteboardId, userId, annotation, Annotations) {
check(meetingId, String);
check(whiteboardId, String);
check(annotation, Object);
const {
2023-03-01 22:52:39 +08:00
id, wbId,
} = annotation;
let { annotationInfo } = annotation;
const selector = {
meetingId,
id,
};
const oldAnnotation = await Annotations.findOneAsync(selector);
if (oldAnnotation) {
2023-03-01 22:52:39 +08:00
annotationInfo = defaultsDeep(annotationInfo, oldAnnotation.annotationInfo);
}
const modifier = {
$set: {
whiteboardId,
meetingId,
id,
annotationInfo,
wbId,
},
};
return { selector, modifier };
}
export default addAnnotation;