2019-06-14 10:18:36 +08:00
|
|
|
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/note/server/helpers';
|
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;
|
|
|
|
if (status === 200) {
|
2019-06-22 04:52:54 +08:00
|
|
|
Logger.verbose(`Appended text for padId:${padId}`);
|
2019-06-14 10:18:36 +08:00
|
|
|
}
|
|
|
|
}).catch(error => Logger.error(`Could not append captions for padId=${padId}: ${error}`));
|
|
|
|
}
|