bigbluebutton-Github/bigbluebutton-html5/imports/api/captions/server/modifiers/addCaption.js

44 lines
950 B
JavaScript
Raw Normal View History

2019-05-23 22:51:01 +08:00
import { check } from 'meteor/check';
import Captions from '/imports/api/captions';
2017-01-18 20:53:33 +08:00
import Logger from '/imports/startup/server/logger';
export default function addCaption(meetingId, padId, locale) {
2017-01-18 20:53:33 +08:00
check(meetingId, String);
check(padId, String);
check(locale, {
locale: String,
name: String,
});
2017-01-18 20:53:33 +08:00
const selector = {
meetingId,
padId,
2017-01-18 20:53:33 +08:00
};
2017-06-03 03:25:02 +08:00
const modifier = {
meetingId,
padId,
locale,
2019-05-29 22:31:27 +08:00
ownerId: '',
readOnlyPadId: '',
data: '',
revs: 0,
length: 0,
2017-01-18 20:53:33 +08:00
};
const cb = (err, numChanged) => {
if (err) {
return Logger.error(`Adding caption to collection: ${err}`);
2017-01-18 20:53:33 +08:00
}
const { insertedId } = numChanged;
if (insertedId) {
return Logger.verbose(`Added caption locale=${locale.locale} meeting=${meetingId}`);
2017-01-18 20:53:33 +08:00
}
return Logger.verbose(`Upserted caption locale=${locale.locale} meeting=${meetingId}`);
2017-01-18 20:53:33 +08:00
};
return Captions.upsert(selector, modifier, cb);
2017-06-03 03:25:02 +08:00
}