bigbluebutton-Github/bigbluebutton-html5/imports/api/captions/server/methods/appendText.js
Pedro Beschorner Marin 1aa7685dcc Refactor Etherpad API calls
Isolate most Pad related functions and secure shared notes and closed
captions creation to only when there is a reachable Etherpad server
configured.
2021-03-29 18:35:33 -03:00

28 lines
927 B
JavaScript

import axios from 'axios';
import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
import { generatePadId } from '/imports/api/captions/server/helpers';
import { appendTextURL } from '/imports/api/common/server/etherpad';
import { extractCredentials } from '/imports/api/common/server/helpers';
export default function appendText(text, locale) {
const { meetingId } = extractCredentials(this.userId);
check(meetingId, String);
check(text, String);
check(locale, String);
const padId = generatePadId(meetingId, locale);
axios({
method: 'get',
url: appendTextURL(padId, text),
responseType: 'json',
}).then((response) => {
const { status } = response;
if (status !== 200) {
Logger.error(`Could not append captions for padId=${padId}`);
return;
}
}).catch(error => Logger.error(`Could not append captions for padId=${padId}: ${error}`));
}