bigbluebutton-Github/bigbluebutton-html5/imports/api/captions/server/methods/fetchReadOnlyPadId.js
Pedro Beschorner Marin 741122df96 Closed captions cleanup
2019-05-23 11:51:01 -03:00

27 lines
861 B
JavaScript

import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
import {
getReadOnlyIdURL,
getDataFromResponse,
} from '/imports/api/note/server/helpers';
import updateReadOnlyPadId from '/imports/api/captions/server/modifiers/updateReadOnlyPadId';
import axios from 'axios';
export default function fetchReadOnlyPadId(padId) {
check(padId, String);
const readOnlyURL = getReadOnlyIdURL(padId);
axios({
method: 'get',
url: readOnlyURL,
responseType: 'json',
}).then((response) => {
const readOnlyPadId = getDataFromResponse(response.data, 'readOnlyID');
if (readOnlyPadId) {
updateReadOnlyPadId(padId, readOnlyPadId);
} else {
Logger.error(`Could not get pad readOnlyID for ${padId}`);
}
}).catch(error => Logger.error(`Could not get pad readOnlyID for ${padId}: ${error}`));
}