fix server logic and logs messages related to quotas

This commit is contained in:
ansuz 2022-09-13 13:00:36 +05:30
parent 576b034547
commit 2b365694f6
3 changed files with 6 additions and 5 deletions

View File

@ -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(); }

View File

@ -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);
}
});
};

View File

@ -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();
});
});