From 079d7570092a8bf991053d30c1b05010eeda6cc3 Mon Sep 17 00:00:00 2001 From: naskya Date: Thu, 18 May 2023 20:38:33 +0900 Subject: [PATCH 1/2] Check alt text on mutes --- packages/backend/src/misc/check-word-mute.ts | 3 ++- packages/client/src/scripts/check-word-mute.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/misc/check-word-mute.ts b/packages/backend/src/misc/check-word-mute.ts index 8874a4a051..08ec97751e 100644 --- a/packages/backend/src/misc/check-word-mute.ts +++ b/packages/backend/src/misc/check-word-mute.ts @@ -5,6 +5,7 @@ import type { User } from "@/models/entities/user.js"; type NoteLike = { userId: Note["userId"]; text: Note["text"]; + files: Note["files"]; cw?: Note["cw"]; }; @@ -18,7 +19,7 @@ function checkWordMute( ): boolean { if (note == null) return false; - const text = ((note.cw ?? "") + " " + (note.text ?? "")).trim(); + const text = `${note.cw ?? ""} ${note.text ?? ""} ${note.files.map((f) => f.comment ?? "").join(" ")}`.trim(); if (text === "") return false; for (const mutePattern of mutedWords) { diff --git a/packages/client/src/scripts/check-word-mute.ts b/packages/client/src/scripts/check-word-mute.ts index 3237a2c875..de0414a363 100644 --- a/packages/client/src/scripts/check-word-mute.ts +++ b/packages/client/src/scripts/check-word-mute.ts @@ -10,7 +10,7 @@ function checkWordMute( note: NoteLike, mutedWords: Array, ): Muted { - const text = ((note.cw ?? "") + " " + (note.text ?? "")).trim(); + const text = `${note.cw ?? ""} ${note.text ?? ""} ${note.files.map((f) => f.comment ?? "").join(" ")}`.trim(); if (text === "") return NotMuted; let result = { muted: false, matched: [] }; From 80d4f0696222cf2920fdc90ad310335450a6b9e3 Mon Sep 17 00:00:00 2001 From: naskya Date: Thu, 18 May 2023 20:50:24 +0900 Subject: [PATCH 2/2] format --- packages/backend/src/misc/check-word-mute.ts | 4 +++- packages/client/src/scripts/check-word-mute.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/misc/check-word-mute.ts b/packages/backend/src/misc/check-word-mute.ts index 08ec97751e..61047de19f 100644 --- a/packages/backend/src/misc/check-word-mute.ts +++ b/packages/backend/src/misc/check-word-mute.ts @@ -19,7 +19,9 @@ function checkWordMute( ): boolean { if (note == null) return false; - const text = `${note.cw ?? ""} ${note.text ?? ""} ${note.files.map((f) => f.comment ?? "").join(" ")}`.trim(); + const text = `${note.cw ?? ""} ${note.text ?? ""} ${note.files + .map((f) => f.comment ?? "") + .join(" ")}`.trim(); if (text === "") return false; for (const mutePattern of mutedWords) { diff --git a/packages/client/src/scripts/check-word-mute.ts b/packages/client/src/scripts/check-word-mute.ts index de0414a363..c2943d6ae4 100644 --- a/packages/client/src/scripts/check-word-mute.ts +++ b/packages/client/src/scripts/check-word-mute.ts @@ -10,7 +10,9 @@ function checkWordMute( note: NoteLike, mutedWords: Array, ): Muted { - const text = `${note.cw ?? ""} ${note.text ?? ""} ${note.files.map((f) => f.comment ?? "").join(" ")}`.trim(); + const text = `${note.cw ?? ""} ${note.text ?? ""} ${note.files + .map((f) => f.comment ?? "") + .join(" ")}`.trim(); if (text === "") return NotMuted; let result = { muted: false, matched: [] };