Check alt text on mutes

This commit is contained in:
naskya 2023-05-18 20:38:33 +09:00
parent 60b5aec626
commit 079d757009
No known key found for this signature in database
GPG Key ID: 164DFF24E2D40139
2 changed files with 3 additions and 2 deletions

View File

@ -5,6 +5,7 @@ import type { User } from "@/models/entities/user.js";
type NoteLike = { type NoteLike = {
userId: Note["userId"]; userId: Note["userId"];
text: Note["text"]; text: Note["text"];
files: Note["files"];
cw?: Note["cw"]; cw?: Note["cw"];
}; };
@ -18,7 +19,7 @@ function checkWordMute(
): boolean { ): boolean {
if (note == null) return false; 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; if (text === "") return false;
for (const mutePattern of mutedWords) { for (const mutePattern of mutedWords) {

View File

@ -10,7 +10,7 @@ function checkWordMute(
note: NoteLike, note: NoteLike,
mutedWords: Array<string | string[]>, mutedWords: Array<string | string[]>,
): Muted { ): 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; if (text === "") return NotMuted;
let result = { muted: false, matched: [] }; let result = { muted: false, matched: [] };