2017-10-21 21:10:33 -04:00
|
|
|
"use strict";
|
|
|
|
|
2017-10-15 19:47:05 -04:00
|
|
|
const sql = require('../../services/sql');
|
2018-04-01 21:27:46 -04:00
|
|
|
const optionService = require('../../services/options');
|
2017-10-14 23:31:44 -04:00
|
|
|
|
2018-04-01 17:41:28 -04:00
|
|
|
// options allowed to be updated directly in options dialog
|
2018-04-02 21:47:46 -04:00
|
|
|
const ALLOWED_OPTIONS = ['protectedSessionTimeout', 'noteRevisionSnapshotTimeInterval'];
|
2017-10-14 23:31:44 -04:00
|
|
|
|
2018-04-01 20:33:10 -04:00
|
|
|
async function getOptions() {
|
2018-04-01 17:41:28 -04:00
|
|
|
const options = await sql.getMap("SELECT name, value FROM options WHERE name IN ("
|
2017-11-04 19:57:40 -04:00
|
|
|
+ ALLOWED_OPTIONS.map(x => '?').join(",") + ")", ALLOWED_OPTIONS);
|
2017-10-14 23:31:44 -04:00
|
|
|
|
2018-04-01 17:41:28 -04:00
|
|
|
return options;
|
2018-03-30 13:56:46 -04:00
|
|
|
}
|
2017-10-14 23:31:44 -04:00
|
|
|
|
2018-04-01 17:41:28 -04:00
|
|
|
async function updateOption(req) {
|
2018-04-01 20:33:10 -04:00
|
|
|
const {name, value} = req.params;
|
2017-10-14 23:31:44 -04:00
|
|
|
|
2018-04-01 20:33:10 -04:00
|
|
|
if (!ALLOWED_OPTIONS.includes(name)) {
|
2018-03-30 13:56:46 -04:00
|
|
|
return [400, "not allowed option to set"];
|
2017-10-14 23:31:44 -04:00
|
|
|
}
|
|
|
|
|
2018-04-01 21:27:46 -04:00
|
|
|
await optionService.setOption(name, value);
|
2018-03-30 13:56:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
2018-04-01 20:33:10 -04:00
|
|
|
getOptions,
|
2018-04-01 17:41:28 -04:00
|
|
|
updateOption
|
2018-03-30 13:56:46 -04:00
|
|
|
};
|