diff options
| author | anatawa12 <anatawa12@icloud.com> | 2025-05-29 13:13:07 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-29 13:13:07 +0900 |
| commit | 367dac4edd4e25281b2978e7d509e9a57a002bdb (patch) | |
| tree | c2c01effada893d224261bff5f8fe07f6f4b67a7 /packages/backend/src/misc | |
| parent | fix tests (diff) | |
| download | misskey-367dac4edd4e25281b2978e7d509e9a57a002bdb.tar.gz misskey-367dac4edd4e25281b2978e7d509e9a57a002bdb.tar.bz2 misskey-367dac4edd4e25281b2978e7d509e9a57a002bdb.zip | |
Fix: ミュート対象ユーザーが引用されているノートがRNされたときにミュートを貫通してしまう問題 (#16009)
* chore: change 3rd parameter of generateMutedUserQueryForNotes to options
* chore: allow specifying note column for note/block query
* chore: check for mute / block for renote of note with DB query
* chore: check for mute / block for renote of note with FTT
* refactor: ミュート・ブロックのためのクエリ呼び出しを一つの関数にまとめる
* docs(changelog): ミュート対象ユーザーが引用されているノートがRNされたときにミュートを貫通してしまう問題を修正
* fix missing default parameter
* Update is-user-related.ts
* test: add tests for mutes
---------
Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
Diffstat (limited to 'packages/backend/src/misc')
| -rw-r--r-- | packages/backend/src/misc/is-user-related.ts | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/packages/backend/src/misc/is-user-related.ts b/packages/backend/src/misc/is-user-related.ts index 862d6e6a38..6f72082733 100644 --- a/packages/backend/src/misc/is-user-related.ts +++ b/packages/backend/src/misc/is-user-related.ts @@ -3,7 +3,17 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -export function isUserRelated(note: any, userIds: Set<string>, ignoreAuthor = false): boolean { +import type { MiUser } from '@/models/_.js'; + +interface NoteLike { + userId: MiUser['id']; + reply?: NoteLike | null; + renote?: NoteLike | null; + replyUserId?: MiUser['id'] | null; + renoteUserId?: MiUser['id'] | null; +} + +export function isUserRelated(note: NoteLike | null | undefined, userIds: Set<string>, ignoreAuthor = false): boolean { if (!note) { return false; } @@ -12,13 +22,16 @@ export function isUserRelated(note: any, userIds: Set<string>, ignoreAuthor = fa return true; } - if (note.reply != null && note.reply.userId !== note.userId && userIds.has(note.reply.userId)) { + const replyUserId = note.replyUserId ?? note.reply?.userId; + if (replyUserId != null && replyUserId !== note.userId && userIds.has(replyUserId)) { return true; } - if (note.renote != null && note.renote.userId !== note.userId && userIds.has(note.renote.userId)) { + const renoteUserId = note.renoteUserId ?? note.renote?.userId; + if (renoteUserId != null && renoteUserId !== note.userId && userIds.has(renoteUserId)) { return true; } return false; } + |