From 1bcd90281795d6922b3a8ba14a28bffd573588cd Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Tue, 11 Feb 2020 13:02:43 +0700 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=BA=D1=80=D1=8B=D1=82=D0=B0=20?= =?UTF-8?q?=D0=B4=D1=8B=D1=80=D0=B0=20=D0=B1=D0=B5=D0=B7=D0=BE=D0=BF=D0=B0?= =?UTF-8?q?=D1=81=D0=BD=D0=BE=D1=81=D1=82=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/api/misc.js | 3 ++- server/config/base.js | 3 ++- server/controllers/MiscController.js | 7 +++++-- server/controllers/WebSocketController.js | 4 +++- 4 files changed, 12 insertions(+), 5 deletions(-) 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'); }