diff --git a/packages/backend/src/misc/check-hit-antenna.ts b/packages/backend/src/misc/check-hit-antenna.ts index 270a58cf13..199b2d9647 100644 --- a/packages/backend/src/misc/check-hit-antenna.ts +++ b/packages/backend/src/misc/check-hit-antenna.ts @@ -9,6 +9,7 @@ import { Cache } from "./cache.js"; import { getWordHardMute } from "./check-word-mute.js"; const blockingCache = new Cache("blocking", 60 * 5); +const mutedWordsCache = new Cache("mutedWords", 60 * 5); export async function checkHitAntenna( antenna: Antenna, @@ -22,14 +23,6 @@ export async function checkHitAntenna( if (note.fileIds && note.fileIds.length === 0) return false; } - // アンテナ作成者がノート作成者にブロックされていたらスキップ - const blockings = await blockingCache.fetch(noteUser.id, () => - Blockings.findBy({ blockerId: noteUser.id }).then((res) => - res.map((x) => x.blockeeId), - ), - ); - if (blockings.some((blocking) => blocking === antenna.userId)) return false; - if (antenna.src === "users") { const accts = antenna.users.map((x) => { const { username, host } = Acct.parse(x); @@ -88,16 +81,20 @@ export async function checkHitAntenna( if (matched) return false; } - if ( - await getWordHardMute( - note, - antenna.userId, - ( - await UserProfiles.findOneBy({ userId: antenna.userId }) - )?.mutedWords, - ) - ) - return false; + // アンテナ作成者がノート作成者にブロックされていたらスキップ + const blockings = await blockingCache.fetch(noteUser.id, () => + Blockings.findBy({ blockerId: noteUser.id }).then((res) => + res.map((x) => x.blockeeId), + ), + ); + if (blockings.includes(antenna.userId)) return false; + + const mutedWords = await mutedWordsCache.fetch(antenna.userId, () => + UserProfiles.findOneBy({ userId: antenna.userId }).then( + (profile) => profile?.mutedWords, + ), + ); + if (await getWordHardMute(note, antenna.userId, mutedWords)) return false; // TODO: eval expression