2019-06-14 10:18:36 +08:00
|
|
|
import axios from 'axios';
|
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
2021-03-30 05:35:33 +08:00
|
|
|
import { generatePadId } from '/imports/api/captions/server/helpers';
|
|
|
|
import { appendTextURL } from '/imports/api/common/server/etherpad';
|
2020-04-30 21:46:30 +08:00
|
|
|
import { extractCredentials } from '/imports/api/common/server/helpers';
|
2019-06-14 10:18:36 +08:00
|
|
|
|
2020-04-30 21:46:30 +08:00
|
|
|
export default function appendText(text, locale) {
|
|
|
|
const { meetingId } = extractCredentials(this.userId);
|
2019-06-14 10:18:36 +08:00
|
|
|
check(meetingId, String);
|
2019-06-22 04:52:54 +08:00
|
|
|
check(text, String);
|
2019-06-18 22:36:22 +08:00
|
|
|
check(locale, String);
|
2019-06-14 10:18:36 +08:00
|
|
|
|
2019-06-18 22:36:22 +08:00
|
|
|
const padId = generatePadId(meetingId, locale);
|
2019-06-14 10:18:36 +08:00
|
|
|
|
|
|
|
axios({
|
|
|
|
method: 'get',
|
2019-06-22 04:52:54 +08:00
|
|
|
url: appendTextURL(padId, text),
|
2019-06-14 10:18:36 +08:00
|
|
|
responseType: 'json',
|
|
|
|
}).then((response) => {
|
|
|
|
const { status } = response;
|
2021-02-09 23:59:59 +08:00
|
|
|
if (status !== 200) {
|
|
|
|
Logger.error(`Could not append captions for padId=${padId}`);
|
|
|
|
return;
|
2019-06-14 10:18:36 +08:00
|
|
|
}
|
|
|
|
}).catch(error => Logger.error(`Could not append captions for padId=${padId}: ${error}`));
|
|
|
|
}
|