bigbluebutton-Github/bigbluebutton-html5/imports/api/captions/server/methods/fetchReadOnlyPadId.js

27 lines
861 B
JavaScript
Raw Normal View History

import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
import {
getReadOnlyIdURL,
getDataFromResponse,
} from '/imports/api/note/server/helpers';
2019-05-23 22:51:01 +08:00
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) => {
2019-05-23 22:51:01 +08:00
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}`));
}