2017-12-13 23:03:48 -05:00
|
|
|
"use strict";
|
|
|
|
|
2025-01-04 11:52:40 +02:00
|
|
|
import optionService from "./options.js";
|
2024-07-18 21:35:17 +03:00
|
|
|
import config from "./config.js";
|
2018-08-28 21:13:40 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2025-01-24 00:02:45 +01:00
|
|
|
function get(name: keyof typeof config.Sync) {
|
2025-03-02 20:47:57 +01:00
|
|
|
return (config["Sync"] && config["Sync"][name]) || optionService.getOption(name);
|
2018-08-28 21:13:40 +02:00
|
|
|
}
|
2017-12-13 23:03:48 -05:00
|
|
|
|
2024-07-18 21:47:30 +03:00
|
|
|
export default {
|
2023-01-06 15:14:04 +01:00
|
|
|
// env variable is the easiest way to guarantee we won't overwrite prod data during development
|
|
|
|
// after copying prod document/data directory
|
2025-01-24 00:03:50 +01:00
|
|
|
getSyncServerHost: () => get("syncServerHost"),
|
2020-06-20 12:31:38 +02:00
|
|
|
isSyncSetup: () => {
|
2025-01-09 18:07:02 +02:00
|
|
|
const syncServerHost = get("syncServerHost");
|
2018-12-22 09:54:09 +01:00
|
|
|
|
2023-06-30 11:18:34 +02:00
|
|
|
// special value "disabled" is here to support a use case where the document is configured with sync server,
|
2018-12-22 09:54:09 +01:00
|
|
|
// and we need to override it with config from config.ini
|
2025-01-09 18:07:02 +02:00
|
|
|
return !!syncServerHost && syncServerHost !== "disabled";
|
2018-12-22 09:54:09 +01:00
|
|
|
},
|
2025-01-09 18:07:02 +02:00
|
|
|
getSyncTimeout: () => parseInt(get("syncServerTimeout")) || 120000,
|
|
|
|
getSyncProxy: () => get("syncProxy")
|
2020-06-20 12:31:38 +02:00
|
|
|
};
|