2017-12-14 12:03:48 +08:00
|
|
|
"use strict";
|
|
|
|
|
2018-07-23 04:21:16 +08:00
|
|
|
const optionService = require('./options');
|
2018-08-29 03:13:40 +08:00
|
|
|
const config = require('./config');
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Primary configuration for sync is in the options (document), but we allow to override
|
|
|
|
* these settings in config file. The reason for that is to avoid a mistake of loading a live/production
|
|
|
|
* document with live sync settings in a dev/debug environment. Changes would then successfully propagate
|
|
|
|
* to live sync server.
|
|
|
|
*/
|
|
|
|
|
|
|
|
async function get(name) {
|
2018-08-31 05:28:38 +08:00
|
|
|
return (config['Sync'] && config['Sync'][name]) || await optionService.getOption(name);
|
2018-08-29 03:13:40 +08:00
|
|
|
}
|
2017-12-14 12:03:48 +08:00
|
|
|
|
|
|
|
module.exports = {
|
2018-08-29 03:13:40 +08:00
|
|
|
getSyncServerHost: async () => await get('syncServerHost'),
|
2018-12-22 16:54:09 +08:00
|
|
|
isSyncSetup: async () => {
|
|
|
|
const syncServerHost = await get('syncServerHost');
|
|
|
|
|
|
|
|
// special value "disabled" is here to support use case where document is configured with sync server
|
|
|
|
// and we need to override it with config from config.ini
|
|
|
|
return !!syncServerHost && syncServerHost !== 'disabled';
|
|
|
|
},
|
2019-12-29 17:19:00 +08:00
|
|
|
getSyncTimeout: async () => parseInt(await get('syncServerTimeout')) || 60000,
|
2018-08-29 03:13:40 +08:00
|
|
|
getSyncProxy: async () => await get('syncProxy')
|
2017-12-14 12:03:48 +08:00
|
|
|
};
|