2021-10-16 03:07:13 +08:00
|
|
|
import axios from 'axios';
|
2019-05-17 04:11:10 +08:00
|
|
|
import { Meteor } from 'meteor/meteor';
|
2021-10-16 03:07:13 +08:00
|
|
|
import createCaptions from '/imports/api/captions/server/modifiers/createCaptions';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
2019-05-17 04:11:10 +08:00
|
|
|
|
|
|
|
const CAPTIONS_CONFIG = Meteor.settings.public.captions;
|
2019-05-23 22:51:01 +08:00
|
|
|
const BASENAME = Meteor.settings.public.app.basename;
|
2021-10-16 03:07:13 +08:00
|
|
|
const HOST = Meteor.settings.private.app.host;
|
|
|
|
const LOCALES = Meteor.settings.private.app.localesUrl;
|
|
|
|
const LOCALES_URL = `http://${HOST}:${process.env.PORT}${BASENAME}${LOCALES}`;
|
|
|
|
|
|
|
|
const init = (meetingId) => {
|
|
|
|
axios({
|
|
|
|
method: 'get',
|
|
|
|
url: LOCALES_URL,
|
|
|
|
responseType: 'json',
|
|
|
|
}).then((response) => {
|
|
|
|
const { status } = response;
|
|
|
|
if (status !== 200) return;
|
|
|
|
|
|
|
|
const locales = response.data;
|
|
|
|
locales.forEach((locale) => createCaptions(meetingId, locale.locale, locale.name));
|
|
|
|
}).catch((error) => Logger.error(`Could not create captions for ${meetingId}: ${error}`));
|
2019-05-23 22:51:01 +08:00
|
|
|
};
|
2019-05-17 04:11:10 +08:00
|
|
|
|
2021-10-16 03:07:13 +08:00
|
|
|
const initCaptions = (meetingId) => {
|
|
|
|
if (CAPTIONS_CONFIG.enabled) init(meetingId);
|
2019-05-17 04:11:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
export {
|
2021-10-16 03:07:13 +08:00
|
|
|
initCaptions,
|
2019-05-17 04:11:10 +08:00
|
|
|
};
|