mirror of
https://github.com/zadam/trilium.git
synced 2025-11-16 10:15:52 +01:00
#98, sync is now configured in the options
This commit is contained in:
@@ -5,7 +5,8 @@ const optionService = require('../../services/options');
|
||||
const log = require('../../services/log');
|
||||
|
||||
// options allowed to be updated directly in options dialog
|
||||
const ALLOWED_OPTIONS = ['protectedSessionTimeout', 'noteRevisionSnapshotTimeInterval', 'zoomFactor', 'theme'];
|
||||
const ALLOWED_OPTIONS = ['protectedSessionTimeout', 'noteRevisionSnapshotTimeInterval',
|
||||
'zoomFactor', 'theme', 'syncServerHost', 'syncServerTimeout', 'syncProxy'];
|
||||
|
||||
async function getOptions() {
|
||||
const options = await sql.getMap("SELECT name, value FROM options WHERE name IN ("
|
||||
@@ -17,16 +18,35 @@ async function getOptions() {
|
||||
async function updateOption(req) {
|
||||
const {name, value} = req.params;
|
||||
|
||||
if (!update(name, value)) {
|
||||
return [400, "not allowed option to change"];
|
||||
}
|
||||
}
|
||||
|
||||
async function updateOptions(req) {
|
||||
for (const optionName in req.body) {
|
||||
if (!update(optionName, req.body[optionName])) {
|
||||
// this should be improved
|
||||
// it should return 400 instead of current 500, but at least it now rollbacks transaction
|
||||
throw new Error(`${optionName} is not allowed to change`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function update(name, value) {
|
||||
if (!ALLOWED_OPTIONS.includes(name)) {
|
||||
return [400, "not allowed option to set"];
|
||||
return false;
|
||||
}
|
||||
|
||||
log.info(`Updating option ${name} to ${value}`);
|
||||
|
||||
await optionService.setOption(name, value);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getOptions,
|
||||
updateOption
|
||||
updateOption,
|
||||
updateOptions
|
||||
};
|
||||
Reference in New Issue
Block a user