files may be undefined
This commit is contained in:
parent
3146749a30
commit
813fb25d72
|
@ -5,7 +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"];
|
files?: Note["files"];
|
||||||
cw?: Note["cw"];
|
cw?: Note["cw"];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -19,9 +19,11 @@ function checkWordMute(
|
||||||
): boolean {
|
): boolean {
|
||||||
if (note == null) return false;
|
if (note == null) return false;
|
||||||
|
|
||||||
const text = `${note.cw ?? ""} ${note.text ?? ""} ${note.files
|
let text = `${note.cw ?? ""} ${note.text ?? ""}`;
|
||||||
.map((f) => f.comment ?? "")
|
if (note.files != null)
|
||||||
.join(" ")}`.trim();
|
text += ` ${note.files.map((f) => f.comment ?? "").join(" ")}`;
|
||||||
|
text = text.trim();
|
||||||
|
|
||||||
if (text === "") return false;
|
if (text === "") return false;
|
||||||
|
|
||||||
for (const mutePattern of mutedWords) {
|
for (const mutePattern of mutedWords) {
|
||||||
|
|
|
@ -10,9 +10,11 @@ function checkWordMute(
|
||||||
note: NoteLike,
|
note: NoteLike,
|
||||||
mutedWords: Array<string | string[]>,
|
mutedWords: Array<string | string[]>,
|
||||||
): Muted {
|
): Muted {
|
||||||
const text = `${note.cw ?? ""} ${note.text ?? ""} ${note.files
|
let text = `${note.cw ?? ""} ${note.text ?? ""}`;
|
||||||
.map((f) => f.comment ?? "")
|
if (note.files != null)
|
||||||
.join(" ")}`.trim();
|
text += ` ${note.files.map((f) => f.comment ?? "").join(" ")}`;
|
||||||
|
text = text.trim();
|
||||||
|
|
||||||
if (text === "") return NotMuted;
|
if (text === "") return NotMuted;
|
||||||
|
|
||||||
let result = { muted: false, matched: [] };
|
let result = { muted: false, matched: [] };
|
||||||
|
|
Loading…
Reference in New Issue