bigbluebutton-Github/bigbluebutton-html5/imports/api/captions/server/modifiers/updatePad.js
2020-11-26 13:23:57 -03:00

36 lines
796 B
JavaScript

import Captions from '/imports/api/captions';
import Logger from '/imports/startup/server/logger';
import editCaptions from '/imports/api/captions/server/methods/editCaptions';
import { check } from 'meteor/check';
export default function updatePad(padId, data, revs) {
check(padId, String);
check(data, String);
check(revs, Number);
const selector = {
padId,
};
const modifier = {
$set: {
data,
revs,
},
$inc: {
length: data.length,
},
};
try {
const numberAffected = Captions.update(selector, modifier, { multi: true });
if (numberAffected) {
editCaptions(padId, data, revs);
Logger.verbose('Captions: updated pad', { padId, revs });
}
} catch (err) {
Logger.error(`Updating captions pad: ${err}`);
}
}