2019-03-29 02:47:11 +08:00
|
|
|
import { Meteor } from 'meteor/meteor';
|
2019-05-17 04:11:10 +08:00
|
|
|
import { hashFNV32a } from '/imports/api/common/server/helpers';
|
2019-03-29 02:47:11 +08:00
|
|
|
|
|
|
|
const ETHERPAD = Meteor.settings.private.etherpad;
|
2019-03-30 02:22:52 +08:00
|
|
|
const NOTE_CONFIG = Meteor.settings.public.note;
|
2019-03-29 02:47:11 +08:00
|
|
|
const BASE_URL = `http://${ETHERPAD.host}:${ETHERPAD.port}/api/${ETHERPAD.version}`;
|
|
|
|
|
2019-05-29 22:31:27 +08:00
|
|
|
const createPadURL = padId => `${BASE_URL}/createPad?apikey=${ETHERPAD.apikey}&padID=${padId}`;
|
2019-03-29 02:47:11 +08:00
|
|
|
|
2019-05-29 22:31:27 +08:00
|
|
|
const getReadOnlyIdURL = padId => `${BASE_URL}/getReadOnlyID?apikey=${ETHERPAD.apikey}&padID=${padId}`;
|
2019-03-29 02:47:11 +08:00
|
|
|
|
2019-05-29 22:31:27 +08:00
|
|
|
const generateNoteId = (meetingId) => {
|
2019-03-29 02:47:11 +08:00
|
|
|
const noteId = hashFNV32a(meetingId, true);
|
|
|
|
return noteId;
|
|
|
|
};
|
|
|
|
|
2019-05-29 22:31:27 +08:00
|
|
|
const isEnabled = () => NOTE_CONFIG.enabled;
|
2019-03-30 02:22:52 +08:00
|
|
|
|
2019-05-17 04:11:10 +08:00
|
|
|
const getDataFromResponse = (data, key) => {
|
|
|
|
if (data) {
|
|
|
|
const innerData = data.data;
|
|
|
|
if (innerData && innerData[key]) {
|
|
|
|
return innerData[key];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
};
|
|
|
|
|
2019-03-29 02:47:11 +08:00
|
|
|
export {
|
|
|
|
generateNoteId,
|
|
|
|
createPadURL,
|
|
|
|
getReadOnlyIdURL,
|
2019-03-30 02:22:52 +08:00
|
|
|
isEnabled,
|
2019-05-17 04:11:10 +08:00
|
|
|
getDataFromResponse,
|
2019-03-29 02:47:11 +08:00
|
|
|
};
|