2019-05-17 04:11:10 +08:00
|
|
|
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';
|
2019-05-17 04:11:10 +08:00
|
|
|
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);
|
2019-05-17 04:11:10 +08:00
|
|
|
} else {
|
|
|
|
Logger.error(`Could not get pad readOnlyID for ${padId}`);
|
|
|
|
}
|
|
|
|
}).catch(error => Logger.error(`Could not get pad readOnlyID for ${padId}: ${error}`));
|
|
|
|
}
|