From 255590cc3a02366d42d88c7fdd7bc72cf59e213c Mon Sep 17 00:00:00 2001 From: Farhad Jay Date: Sun, 18 Jun 2023 21:21:47 -0700 Subject: [PATCH 1/3] Format punishment stream file --- lib/services/punishment-read-write-stream.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/services/punishment-read-write-stream.js b/lib/services/punishment-read-write-stream.js index 4939873..61e3774 100644 --- a/lib/services/punishment-read-write-stream.js +++ b/lib/services/punishment-read-write-stream.js @@ -124,11 +124,7 @@ class PunishmentReadWriteStream extends Transform { } sendMute(reason, muteDuration, type, user) { - const clampedMutedDuration = _.clamp( - muteDuration, - 0, - this.punishmentCache.maxMuteSeconds, - ); + const clampedMutedDuration = _.clamp(muteDuration, 0, this.punishmentCache.maxMuteSeconds); this.push({ user, duration: clampedMutedDuration, From bf527d15e42007cd3c80cdb3477b90916886bf07 Mon Sep 17 00:00:00 2001 From: Farhad Jay Date: Sun, 18 Jun 2023 21:27:04 -0700 Subject: [PATCH 2/3] Add param annotation to method for clarity --- lib/services/punishment-read-write-stream.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/services/punishment-read-write-stream.js b/lib/services/punishment-read-write-stream.js index 61e3774..db8681e 100644 --- a/lib/services/punishment-read-write-stream.js +++ b/lib/services/punishment-read-write-stream.js @@ -93,6 +93,10 @@ class PunishmentReadWriteStream extends Transform { this.push(punished); } + /** + * @param {Object} punished + * @param {boolean} punished.isBannedWord `true` if this mute was automatically issued as a result of the user typing a banned word + */ handleMute(punished) { getReporter().incrementCounter(METRIC_NAMES.MUTES_GIVEN, 1); let muteDuration = null; From 01488e224e0703fb0d8de9372517c1edc8bbf22a Mon Sep 17 00:00:00 2001 From: Farhad Jay Date: Sun, 18 Jun 2023 21:28:01 -0700 Subject: [PATCH 3/3] Remove invalid argument when writing to stream The second argument of `stream.Writable.write()` is the encoding of the chunk. Node 14 didn't seem to mind that it was set to `true`, which is invalid, but Node 18 does and throws an error as a result. --- lib/commands/implementations/mute.js | 1 - lib/commands/implementations/mutelinks.js | 1 - 2 files changed, 2 deletions(-) diff --git a/lib/commands/implementations/mute.js b/lib/commands/implementations/mute.js index de301cd..ee93fe6 100644 --- a/lib/commands/implementations/mute.js +++ b/lib/commands/implementations/mute.js @@ -22,7 +22,6 @@ function mute(input, services) { parsedDuration, `Muting: ${userToPunish} for ${formatDuration(moment.duration(parsedDuration, 'seconds'))}`, ), - true, ); }); return new CommandOutput(null, null); diff --git a/lib/commands/implementations/mutelinks.js b/lib/commands/implementations/mutelinks.js index 3c254fe..0503f4a 100644 --- a/lib/commands/implementations/mutelinks.js +++ b/lib/commands/implementations/mutelinks.js @@ -63,7 +63,6 @@ function mutelinks(defaultPunishmentDuration) { muteDuration, `${data.user} muted for ${formattedDuration} for posting a link while link muting is on.`, ), - true, ); }); const displayState = state === 'all' ? 'on for all links' : state;