From b31d55a45545db80104873023b02805c0c84550c Mon Sep 17 00:00:00 2001 From: Farhad Jay Date: Wed, 2 Oct 2024 15:48:20 -0700 Subject: [PATCH 1/2] Fix double unmutes on `!aegis` When generating a list of all users to unmute/unban with `!aegis`, we combine the values in the `aegisCache`, an object that maps nuked phrases to affected users, and the `singleUserAegisCache`, an object that maps affected users to nuked phrases. This always results in duplicate entries. Simply omitting the users in the `aegisCache` fixes the issue. The `singleUserAegisCache` is more complete because it includes users who typed the banned phrase after the nuke was issued. --- lib/services/punishment-cache.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/services/punishment-cache.js b/lib/services/punishment-cache.js index 43c4125..4dd1212 100644 --- a/lib/services/punishment-cache.js +++ b/lib/services/punishment-cache.js @@ -109,9 +109,7 @@ class PunishmentCache { } getNukedUsers() { - const singleUsers = _.keys(this.singleUserAegisCache); - const userList = this.aegisCache.map((userEntry) => userEntry.userList); - return _.flatten(_.concat(userList, singleUsers)); + return _.keys(this.singleUserAegisCache); } getAndAddPunishmentDuration(viewer, duration = 0) { From 260ee3b6f3e5a0b49e70166dd8a188427e17908d Mon Sep 17 00:00:00 2001 From: Farhad Jay Date: Wed, 2 Oct 2024 16:00:03 -0700 Subject: [PATCH 2/2] Remove unused `aegisCache` map Operations having to do with issuing nuke punishments and undoing said punishments rely on the `singleUserAegisCache` map and the `nukedPhrases` array. It appears the `aegisCache` offers no utility, so it can be removed. --- lib/services/punishment-cache.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/lib/services/punishment-cache.js b/lib/services/punishment-cache.js index 4dd1212..cc13eef 100644 --- a/lib/services/punishment-cache.js +++ b/lib/services/punishment-cache.js @@ -19,7 +19,6 @@ class PunishmentCache { * @type {Object.} */ this.punishedViewersMap = {}; - this.aegisCache = []; this.singleUserAegisCache = {}; this.timeToLive = config.timeToLiveSeconds || 1800; this.tombStoneInterval = config.tomeStoneIntervalMilliseconds || 120000; @@ -60,7 +59,6 @@ class PunishmentCache { } addNukeToCache(userList, nukedPhrase, duration, isMegaNuke) { - this.aegisCache.push({ nukedPhrase, userList }); this.nukedPhrases.push({ duration, phrase: nukedPhrase, isMegaNuke }); userList.forEach((user) => { this.addUserToAegisCache(user, duration, nukedPhrase); @@ -82,14 +80,6 @@ class PunishmentCache { nukedPhrase.phrase instanceof RegExp ? nukedPhrase.phrase.toString() : nukedPhrase.phrase; return curPhrase.toLowerCase() !== nuke.toLowerCase(); }); - - this.aegisCache = this.aegisCache.filter((nukedPhrase) => { - const curPhrase = - nukedPhrase.nukedPhrase instanceof RegExp - ? nukedPhrase.nukedPhrase.toString() - : nukedPhrase.nukedPhrase; - return curPhrase.toLowerCase() !== nuke.toLowerCase(); - }); } cleanseNukes() {