Fix missing arguments

This commit is contained in:
naskya 2023-05-05 05:17:16 +09:00
parent ebfd07628e
commit fc3296d64f
No known key found for this signature in database
GPG key ID: 164DFF24E2D40139
2 changed files with 16 additions and 6 deletions

View file

@ -16,7 +16,10 @@ function escapeRegExp(x: string): string {
return x.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
}
function checkWordMute(note: NoteLike): boolean {
function checkWordMute(
note: NoteLike,
mutedWords: Array<string | string[]>,
): boolean {
if (note == null) return false;
const text = ((note.cw ?? "") + " " + (note.text ?? "")).trim();
@ -67,7 +70,11 @@ export async function getWordHardMute(
}
if (mutedWords.length > 0) {
return checkWordMute(note) || checkWordMute(reply) || checkWordMute(renote);
return (
checkWordMute(note, mutedWords) ||
checkWordMute(reply, mutedWords) ||
checkWordMute(renote, mutedWords)
);
}
return false;

View file

@ -10,7 +10,10 @@ function escapeRegExp(x: string) {
return x.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
}
function checkWordMute(note: NoteLike): Muted {
function checkWordMute(
note: NoteLike,
mutedWords: Array<string | string[]>,
): Muted {
const text = ((note.cw ?? "") + " " + (note.text ?? "")).trim();
if (text === "") return NotMuted;
@ -57,14 +60,14 @@ export function getWordSoftMute(
}
if (mutedWords.length > 0) {
let noteMuted = checkWordMute(note);
let noteMuted = checkWordMute(note, mutedWords);
if (noteMuted.muted) {
noteMuted.what = "note";
return noteMuted;
}
if (note.reply) {
let replyMuted = checkWordMute(note.reply);
let replyMuted = checkWordMute(note.reply, mutedWords);
if (replyMuted.muted) {
replyMuted.what = "reply";
return replyMuted;
@ -72,7 +75,7 @@ export function getWordSoftMute(
}
if (note.renote) {
let renoteMuted = checkWordMute(note.renote);
let renoteMuted = checkWordMute(note.renote, mutedWords);
if (renoteMuted.muted) {
renoteMuted.what = note.text == null ? "renote" : "quote";
return renoteMuted;