bigbluebutton-Github/bigbluebutton-html5/imports/api/annotations/server/methods/sendAnnotationHelper.js

72 lines
1.9 KiB
JavaScript
Raw Normal View History

import RedisPubSub from '/imports/startup/server/redis';
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
2021-05-04 22:38:56 +08:00
import Logger from '/imports/startup/server/logger';
export default function sendAnnotationHelper(annotation, meetingId, requesterUserId) {
const REDIS_CONFIG = Meteor.settings.private.redis;
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
const EVENT_NAME = 'SendWhiteboardAnnotationPubMsg';
2021-05-04 22:38:56 +08:00
try {
const whiteboardId = annotation.wbId;
2021-05-04 22:38:56 +08:00
check(annotation, Object);
check(whiteboardId, String);
2021-05-04 22:38:56 +08:00
if (annotation.annotationType === 'text') {
check(annotation, {
id: String,
status: String,
2021-05-04 22:38:56 +08:00
annotationType: String,
annotationInfo: {
x: Number,
y: Number,
fontColor: Number,
calcedFontSize: Number,
textBoxWidth: Number,
text: String,
textBoxHeight: Number,
id: String,
whiteboardId: String,
status: String,
fontSize: Number,
dataPoints: String,
type: String,
},
wbId: String,
userId: String,
position: Number,
});
} else {
check(annotation, {
id: String,
status: String,
2021-05-04 22:38:56 +08:00
annotationType: String,
annotationInfo: {
color: Number,
thickness: Number,
points: Array,
id: String,
whiteboardId: String,
status: String,
type: String,
dimensions: Match.Maybe([Number]),
},
wbId: String,
userId: String,
position: Number,
});
}
2021-05-04 22:38:56 +08:00
const payload = {
annotation,
drawEndOnly: true,
};
2021-05-04 22:38:56 +08:00
return RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
} catch (err) {
Logger.error(`Exception while invoking method sendAnnotationHelper ${err.stack}`);
}
}