fix/word-mute #18

Manually merged
sup39 merged 2 commits from fix/word-mute into main 2024-02-23 20:35:18 +09:00
3 changed files with 11 additions and 6 deletions

View file

@ -79,7 +79,7 @@ fn check_word_mute_impl(
let text_lower = text.to_lowercase(); let text_lower = text.to_lowercase();
muted_word_list muted_word_list
.iter() .iter()
.all(|muted_word| text_lower.contains(muted_word)) .all(|muted_word| text_lower.contains(&muted_word.to_lowercase()))
}) })
}) || muted_patterns.iter().any(|muted_pattern| { }) || muted_patterns.iter().any(|muted_pattern| {
Regex::new(convert_regex(muted_pattern).as_str()) Regex::new(convert_regex(muted_pattern).as_str())

View file

@ -7,6 +7,7 @@ import { generateMutedUserQuery } from "@/server/api/common/generate-muted-user-
import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js";
import { generateBlockedUserQuery } from "@/server/api/common/generate-block-query.js"; import { generateBlockedUserQuery } from "@/server/api/common/generate-block-query.js";
import { generateMutedNoteThreadQuery } from "@/server/api/common/generate-muted-note-thread-query.js"; import { generateMutedNoteThreadQuery } from "@/server/api/common/generate-muted-note-thread-query.js";
import { generateMutedNoteQuery } from "@/server/api/common/generate-muted-note-query.js";
export const meta = { export const meta = {
tags: ["notes"], tags: ["notes"],
@ -69,6 +70,7 @@ export default define(meta, paramDef, async (ps, user) => {
generateVisibilityQuery(query, user); generateVisibilityQuery(query, user);
generateMutedUserQuery(query, user); generateMutedUserQuery(query, user);
generateMutedNoteQuery(query, user);
generateMutedNoteThreadQuery(query, user); generateMutedNoteThreadQuery(query, user);
generateBlockedUserQuery(query, user); generateBlockedUserQuery(query, user);

View file

@ -887,14 +887,17 @@ async function createMentionedEvents(
nm: NotificationManager, nm: NotificationManager,
) { ) {
for (const u of mentionedUsers.filter((u) => Users.isLocalUser(u))) { for (const u of mentionedUsers.filter((u) => Users.isLocalUser(u))) {
const threadMuted = await NoteThreadMutings.findOneBy({ const isWordMuted = await MutedNotes.existsBy({
userId: u.id, userId: u.id,
threadId: note.threadId || note.id, noteId: note.id,
}); });
if (isWordMuted) continue;
if (threadMuted) { const isThreadMuted = await NoteThreadMutings.existsBy({
continue; userId: u.id,
} threadId: note.threadId ?? note.id,
});
if (isThreadMuted) continue;
// note with "specified" visibility might not be visible to mentioned users // note with "specified" visibility might not be visible to mentioned users
try { try {