2016-11-19 01:35:28 +08:00
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
2017-10-12 10:00:28 +08:00
|
|
|
import Annotations from '/imports/api/annotations';
|
2018-05-12 00:01:24 +08:00
|
|
|
import addAnnotationQuery from '/imports/api/annotations/addAnnotation';
|
2017-10-12 08:52:57 +08:00
|
|
|
|
2023-03-08 21:32:24 +08:00
|
|
|
export default async function addAnnotation(meetingId, whiteboardId, userId, annotation) {
|
2017-10-12 08:52:57 +08:00
|
|
|
check(meetingId, String);
|
|
|
|
check(whiteboardId, String);
|
|
|
|
check(annotation, Object);
|
|
|
|
|
2023-03-08 21:32:24 +08:00
|
|
|
const query = await addAnnotationQuery(meetingId, whiteboardId, userId, annotation, Annotations);
|
2016-11-19 01:35:28 +08:00
|
|
|
|
2020-11-25 21:54:18 +08:00
|
|
|
try {
|
2023-03-08 21:32:24 +08:00
|
|
|
const { insertedId } = await Annotations.upsertAsync(query.selector, query.modifier);
|
2018-04-24 21:59:13 +08:00
|
|
|
|
2018-04-26 08:41:19 +08:00
|
|
|
if (insertedId) {
|
2020-11-25 21:54:18 +08:00
|
|
|
Logger.info(`Added annotation id=${annotation.id} whiteboard=${whiteboardId}`);
|
2018-04-26 08:41:19 +08:00
|
|
|
}
|
2020-11-25 21:54:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Adding annotation to collection: ${err}`);
|
|
|
|
}
|
2018-04-26 08:41:19 +08:00
|
|
|
}
|