From 2b365694f6d5538cbc002fbb445472e4f4740e91 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 13 Sep 2022 13:00:36 +0530 Subject: [PATCH] fix server logic and logs messages related to quotas --- lib/commands/quota.js | 7 ++++--- lib/rpc.js | 2 +- server.js | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/commands/quota.js b/lib/commands/quota.js index 3a8dbe204..d21fef6a6 100644 --- a/lib/commands/quota.js +++ b/lib/commands/quota.js @@ -189,8 +189,9 @@ var queryQuotaServer = function (Env, cb) { let url = new URL(Env.accounts_api); if (!['https:', 'http:'].includes(url.protocol)) { throw new Error("INVALID_PROTOCOL"); } if (url.protocol === 'http:') { H = Http; } - if (typeof(url.port) === 'number') { options.port = url.port; } - options.host = url.host; + let port = Number(url.port); + if (port && typeof(port) === 'number') { options.port = port; } + options.host = url.hostname; Env.Log.info("USING_CUSTOM_ACCOUNTS_API", { value: Env.accounts_api, }); @@ -241,7 +242,7 @@ Quota.updateCachedLimits = function (Env, _cb) { Quota.applyCustomLimits(Env); - if (!Env.allowSubscriptions && !Env.accounts_api) { return void cb(); } + if (!Env.allowSubscriptions || !Env.accounts_api) { return void cb(); } Quota.queryQuotaServer(Env, function (err, json) { if (err) { return void cb(err); } if (!json) { return void cb(); } diff --git a/lib/rpc.js b/lib/rpc.js index 9922aba20..975e183f9 100644 --- a/lib/rpc.js +++ b/lib/rpc.js @@ -205,7 +205,7 @@ RPC.create = function (Env, cb) { // failure is expected if they have not specified a quota API endpoint if (!Env.accounts_api) { return; } if (e) { - Env.WARN('limitUpdate', e); + Env.WARN('LIMIT_UPDATE', e); } }); }; diff --git a/server.js b/server.js index 0e2944e76..4c59dc2e7 100644 --- a/server.js +++ b/server.js @@ -316,7 +316,7 @@ app.get('/api/updatequota', function (req, res) { res.status(500); return void send500(res); } - Env.log('QUOTA_UPDATED', {}); + Env.Log.info('QUOTA_UPDATED', {}); res.send(); }); });