From 171ad403d998c3ef5f9528e0be034f02064b5f9a Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Wed, 23 Sep 2020 00:25:50 +0300 Subject: [PATCH] Add updateNotificationsForBetaVersions option --- docs/configuration.md | 4 ++++ src/data/cfg.schema.json | 5 +++++ src/data/updates.js | 6 +++--- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index c362e2e..75495c0 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -317,6 +317,10 @@ If enabled, any time a moderator is typing in a modmail thread, the user will se **Default:** `on` If enabled, the bot will automatically check for new bot updates periodically and notify about them at the top of new modmail threads +#### updateNotificationsForBetaVersions +**Default:** `off` +If enabled, update notifications will also be given for new beta versions + #### url **Default:** *None* URL to use for attachment and log links. Defaults to `http://IP:PORT`. diff --git a/src/data/cfg.schema.json b/src/data/cfg.schema.json index 1678530..57a36fd 100644 --- a/src/data/cfg.schema.json +++ b/src/data/cfg.schema.json @@ -265,6 +265,11 @@ "default": true }, + "updateNotificationsForBetaVersions": { + "$ref": "#/definitions/customBoolean", + "default": false + }, + "plugins": { "type": "array", "items": { diff --git a/src/data/updates.js b/src/data/updates.js index 02b8cf1..46ef8c2 100644 --- a/src/data/updates.js +++ b/src/data/updates.js @@ -62,10 +62,10 @@ async function refreshVersions() { const parsed = JSON.parse(data); if (! Array.isArray(parsed) || parsed.length === 0) return; - const latestStableRelease = parsed.find(r => ! r.prerelease && ! r.draft); - if (! latestStableRelease) return; + const latestMatchingRelease = parsed.find(r => ! r.draft && (config.updateNotificationsForBetaVersions || ! r.prerelease)); + if (! latestMatchingRelease) return; - const latestVersion = latestStableRelease.name; + const latestVersion = latestMatchingRelease.name; await knex("updates").update({ available_version: latestVersion, last_checked: moment.utc().format("YYYY-MM-DD HH:mm:ss")