bigbluebutton-Github/bigbluebutton-html5/imports/api/pads/server/modifiers/contentPad.js
2022-06-03 14:00:44 -03:00

34 lines
906 B
JavaScript

import { check } from 'meteor/check';
import { patch } from '@mconf/bbb-diff';
import { PadsUpdates } from '/imports/api/pads';
import Logger from '/imports/startup/server/logger';
export default function contentPad(meetingId, externalId, start, end, text) {
try {
check(meetingId, String);
check(externalId, String);
check(start, Number);
check(end, Number);
check(text, String);
const selector = {
meetingId,
externalId,
};
const pad = PadsUpdates.findOne(selector);
const content = (pad && pad.content) ? pad.content : '';
const modifier = {
$set: {
content: patch(content, { start, end, text }),
},
};
PadsUpdates.upsert(selector, modifier);
Logger.debug(`Added pad content external=${externalId} meeting=${meetingId}`);
} catch (err) {
Logger.error(`Adding pad content to the collection: ${err}`);
}
}