From 89ee0afd619e3047082687175fe26d82ebe6e327 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 30 Aug 2020 11:17:26 -0400 Subject: [PATCH] Only accept new user count if higher + add to example config --- config.json.example | 1 + src/routes/getTotalStats.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/config.json.example b/config.json.example index 22971d9..57fa901 100644 --- a/config.json.example +++ b/config.json.example @@ -8,6 +8,7 @@ "discordReportChannelWebhookURL": null, //URL from discord if you would like notifications when someone makes a report [optional] "discordFirstTimeSubmissionsWebhookURL": null, //URL from discord if you would like notifications when someone makes a first time submission [optional] "discordCompletelyIncorrectReportWebhookURL": null, //URL from discord if you would like notifications when someone reports a submission as completely incorrect [optional] + "userCounterURL": null, // For user counting. URL to instance of https://github.com/ajayyy/PrivacyUserCount "proxySubmission": null, // Base url to proxy submissions to persist // e.g. https://sponsor.ajay.app (no trailing slash) "behindProxy": "X-Forwarded-For", //Options: "X-Forwarded-For", "Cloudflare", "X-Real-IP", anything else will mean it is not behind a proxy. True defaults to "X-Forwarded-For" "db": "./databases/sponsorTimes.db", diff --git a/src/routes/getTotalStats.js b/src/routes/getTotalStats.js index ba521e3..103617a 100644 --- a/src/routes/getTotalStats.js +++ b/src/routes/getTotalStats.js @@ -39,7 +39,7 @@ module.exports = function getTotalStats (req, res) { function updateExtensionUsers() { if (config.userCounterURL) { request.get(config.userCounterURL + "/api/v1/userCount", (err, response, body) => { - apiUsersCache = JSON.parse(body).userCount; + apiUsersCache = Math.max(apiUsersCache, JSON.parse(body).userCount); }); }