diff --git a/client/api/misc.js b/client/api/misc.js index 970b4799..aeedc173 100644 --- a/client/api/misc.js +++ b/client/api/misc.js @@ -14,7 +14,8 @@ class Misc { try { await wsc.open(); - return await wsc.message(wsc.send(Object.assign({action: 'get-config'}, query))); + const config = await wsc.message(wsc.send(Object.assign({action: 'get-config'}, query))); + return config; } catch (e) { console.error(e); } diff --git a/server/config/base.js b/server/config/base.js index 7370cec7..f7506800 100644 --- a/server/config/base.js +++ b/server/config/base.js @@ -21,7 +21,8 @@ module.exports = { maxTempPublicDirSize: 512*1024*1024,//512Мб maxUploadPublicDirSize: 200*1024*1024,//100Мб - useExternalBookConverter: false, + useExternalBookConverter: false, + webConfigParams: ['name', 'version', 'mode', 'maxUploadFileSize', 'useExternalBookConverter', 'branch'], db: [ { diff --git a/server/controllers/MiscController.js b/server/controllers/MiscController.js index 84385462..ca26e0fd 100644 --- a/server/controllers/MiscController.js +++ b/server/controllers/MiscController.js @@ -3,8 +3,11 @@ const _ = require('lodash'); class MiscController extends BaseController { async getConfig(req, res) { - if (Array.isArray(req.body.params)) - return _.pick(this.config, req.body.params); + if (Array.isArray(req.body.params)) { + const paramsSet = new Set(req.body.params); + + return _.pick(this.config, this.config.webConfigParams.filter(x => paramsSet.has(x))); + } //bad request res.status(400).send({error: 'params is not an array'}); return false; diff --git a/server/controllers/WebSocketController.js b/server/controllers/WebSocketController.js index af73f175..b744b035 100644 --- a/server/controllers/WebSocketController.js +++ b/server/controllers/WebSocketController.js @@ -98,7 +98,9 @@ class WebSocketController { async getConfig(req, ws) { if (Array.isArray(req.params)) { - this.send(_.pick(this.config, req.params), req, ws); + const paramsSet = new Set(req.params); + + this.send(_.pick(this.config, this.config.webConfigParams.filter(x => paramsSet.has(x))), req, ws); } else { throw new Error('params is not an array'); }