From 959aba6b1370e4ceb9b046ec5dc1fda5573ddd8d Mon Sep 17 00:00:00 2001 From: Sayamame-beans <61457993+Sayamame-beans@users.noreply.github.com> Date: Sun, 23 Jun 2024 12:14:46 +0000 Subject: [PATCH 01/11] fix(backend): mention was not considered for mute --- packages/backend/src/misc/is-user-related.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/backend/src/misc/is-user-related.ts b/packages/backend/src/misc/is-user-related.ts index 93c9b2b814..1604fd0419 100644 --- a/packages/backend/src/misc/is-user-related.ts +++ b/packages/backend/src/misc/is-user-related.ts @@ -8,6 +8,10 @@ export function isUserRelated(note: any, userIds: Set, ignoreAuthor = fa return true; } + if (note.mentions != null && note.mentions.filter(userId => userId !== note.userId && userIds.has(userId)).length > 0) { + return true; + } + if (note.reply != null && note.reply.userId !== note.userId && userIds.has(note.reply.userId)) { return true; } From b8a4a336951dcda9aee1a73f019a788ebe3d0040 Mon Sep 17 00:00:00 2001 From: Sayamame-beans <61457993+Sayamame-beans@users.noreply.github.com> Date: Sun, 23 Jun 2024 12:15:44 +0000 Subject: [PATCH 02/11] fix(backend): visibleUserIds was not considered for mute --- packages/backend/src/misc/is-user-related.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/backend/src/misc/is-user-related.ts b/packages/backend/src/misc/is-user-related.ts index 1604fd0419..a15e7b5f1f 100644 --- a/packages/backend/src/misc/is-user-related.ts +++ b/packages/backend/src/misc/is-user-related.ts @@ -12,6 +12,10 @@ export function isUserRelated(note: any, userIds: Set, ignoreAuthor = fa return true; } + if (note.visibleUserIds != null && note.visibleUserIds.filter(userId => userId !== note.userId && userIds.has(userId)).length > 0) { + return true; + } + if (note.reply != null && note.reply.userId !== note.userId && userIds.has(note.reply.userId)) { return true; } From 51e4897fb8547d716894ce214f2f070537abc0ea Mon Sep 17 00:00:00 2001 From: Sayamame-beans <61457993+Sayamame-beans@users.noreply.github.com> Date: Sun, 23 Jun 2024 12:18:23 +0000 Subject: [PATCH 03/11] docs(changelog): update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 354bbd20fd..212066aae8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ - Fix: 自分以外のクリップ内のノート個数が見えることがあるのを修正 - Fix: 空文字列のリアクションはフォールバックされるように - Fix: リノートにリアクションできないように +- Fix: ユーザーミュート対象へのメンションが含まれたノートがミュートされていなかった問題を修正 ## 2024.5.0 From 0bcd79b5775712bfac965da5a200d454ef2d2d5e Mon Sep 17 00:00:00 2001 From: Sayamame-beans <61457993+Sayamame-beans@users.noreply.github.com> Date: Sun, 23 Jun 2024 12:19:18 +0000 Subject: [PATCH 04/11] docs(changelog): update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 212066aae8..0dbb454675 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ - Fix: 空文字列のリアクションはフォールバックされるように - Fix: リノートにリアクションできないように - Fix: ユーザーミュート対象へのメンションが含まれたノートがミュートされていなかった問題を修正 +- Fix: ユーザーミュート対象を宛先に含むダイレクト投稿がミュートされていなかった問題を修正 ## 2024.5.0 From 3d2b495829be7f3b841ad5c8979f8f8e1f778052 Mon Sep 17 00:00:00 2001 From: Sayamame-beans <61457993+Sayamame-beans@users.noreply.github.com> Date: Mon, 15 Jul 2024 22:48:13 +0900 Subject: [PATCH 05/11] Revert "fix(backend): visibleUserIds was not considered for mute" This reverts commit b8a4a336951dcda9aee1a73f019a788ebe3d0040. --- packages/backend/src/misc/is-user-related.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/backend/src/misc/is-user-related.ts b/packages/backend/src/misc/is-user-related.ts index a15e7b5f1f..1604fd0419 100644 --- a/packages/backend/src/misc/is-user-related.ts +++ b/packages/backend/src/misc/is-user-related.ts @@ -12,10 +12,6 @@ export function isUserRelated(note: any, userIds: Set, ignoreAuthor = fa return true; } - if (note.visibleUserIds != null && note.visibleUserIds.filter(userId => userId !== note.userId && userIds.has(userId)).length > 0) { - return true; - } - if (note.reply != null && note.reply.userId !== note.userId && userIds.has(note.reply.userId)) { return true; } From 6d07f683eb03d88b3ba115dc7c15c363d85d41c1 Mon Sep 17 00:00:00 2001 From: Sayamame-beans <61457993+Sayamame-beans@users.noreply.github.com> Date: Mon, 15 Jul 2024 22:48:20 +0900 Subject: [PATCH 06/11] Revert "docs(changelog): update changelog" This reverts commit 0bcd79b5775712bfac965da5a200d454ef2d2d5e. --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0dbb454675..212066aae8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,6 @@ - Fix: 空文字列のリアクションはフォールバックされるように - Fix: リノートにリアクションできないように - Fix: ユーザーミュート対象へのメンションが含まれたノートがミュートされていなかった問題を修正 -- Fix: ユーザーミュート対象を宛先に含むダイレクト投稿がミュートされていなかった問題を修正 ## 2024.5.0 From 446238026a35f16e82eb5cefd87d8ae6e133f42d Mon Sep 17 00:00:00 2001 From: Sayamame-beans <61457993+Sayamame-beans@users.noreply.github.com> Date: Mon, 18 Nov 2024 22:58:39 +0900 Subject: [PATCH 07/11] fix(backend): mention was not considered for mute (query ver) --- packages/backend/src/core/QueryService.ts | 11 ++++++++++- .../src/server/api/endpoints/notes/mentions.ts | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/core/QueryService.ts b/packages/backend/src/core/QueryService.ts index c4feeaf971..1d78a991fc 100644 --- a/packages/backend/src/core/QueryService.ts +++ b/packages/backend/src/core/QueryService.ts @@ -127,7 +127,7 @@ export class QueryService { } @bindThis - public generateMutedUserQuery(q: SelectQueryBuilder, me: { id: MiUser['id'] }, exclude?: { id: MiUser['id'] }): void { + public generateMutedUserQuery(q: SelectQueryBuilder, me: { id: MiUser['id'] }, exclude?: { id: MiUser['id'] }, checkMentions: boolean = true): void { const mutingQuery = this.mutingsRepository.createQueryBuilder('muting') .select('muting.muteeId') .where('muting.muterId = :muterId', { muterId: me.id }); @@ -172,6 +172,15 @@ export class QueryService { .orWhere(`NOT ((${ mutingInstanceQuery.getQuery() })::jsonb ? note.renoteUserHost)`); })); + // 投稿に含まれるメンションの相手をミュートしていない + if (checkMentions) { + q.andWhere(new Brackets(qb => { + qb + .where('note.mentions IS NULL') + .orWhere(`NOT (note.mentions && (${ mutingQuery.getQuery() }))`); + })); + } + q.setParameters(mutingQuery.getParameters()); q.setParameters(mutingInstanceQuery.getParameters()); } diff --git a/packages/backend/src/server/api/endpoints/notes/mentions.ts b/packages/backend/src/server/api/endpoints/notes/mentions.ts index 5558dd3a8b..8e138bc880 100644 --- a/packages/backend/src/server/api/endpoints/notes/mentions.ts +++ b/packages/backend/src/server/api/endpoints/notes/mentions.ts @@ -74,7 +74,7 @@ export default class extends Endpoint { // eslint- .leftJoinAndSelect('renote.user', 'renoteUser'); this.queryService.generateVisibilityQuery(query, me); - this.queryService.generateMutedUserQuery(query, me); + this.queryService.generateMutedUserQuery(query, me, undefined, false); // 通知系ではメンションを確認しないようにする this.queryService.generateMutedNoteThreadQuery(query, me); this.queryService.generateBlockedUserQuery(query, me); From bcf255a00b04e7f820f84c015f2a503b629002d0 Mon Sep 17 00:00:00 2001 From: Sayamame-beans <61457993+Sayamame-beans@users.noreply.github.com> Date: Mon, 18 Nov 2024 23:13:37 +0900 Subject: [PATCH 08/11] docs(changelog): update changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 212066aae8..b435bbca7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,7 +27,8 @@ - Fix: 自分以外のクリップ内のノート個数が見えることがあるのを修正 - Fix: 空文字列のリアクションはフォールバックされるように - Fix: リノートにリアクションできないように -- Fix: ユーザーミュート対象へのメンションが含まれたノートがミュートされていなかった問題を修正 +- Fix: ユーザーミュートにおいて、ノート内のメンションが考慮されていなかった問題を修正 + - これにより、第三者から自分に対するノートを意図せず取り逃してしまう可能性があったため、通知欄ではメンションを考慮しないままになっています ## 2024.5.0 From 32f4b639c904607394f87185decd3ddfabc8e5c8 Mon Sep 17 00:00:00 2001 From: Sayamame-beans <61457993+Sayamame-beans@users.noreply.github.com> Date: Mon, 18 Nov 2024 23:35:23 +0900 Subject: [PATCH 09/11] fix(backend): fix lint --- packages/backend/src/misc/is-user-related.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend/src/misc/is-user-related.ts b/packages/backend/src/misc/is-user-related.ts index c8ae441598..87faedd1ca 100644 --- a/packages/backend/src/misc/is-user-related.ts +++ b/packages/backend/src/misc/is-user-related.ts @@ -12,7 +12,7 @@ export function isUserRelated(note: any, userIds: Set, ignoreAuthor = fa return true; } - if (note.mentions != null && note.mentions.filter(userId => userId !== note.userId && userIds.has(userId)).length > 0) { + if (note.mentions != null && note.mentions.filter((userId: string) => userId !== note.userId && userIds.has(userId)).length > 0) { return true; } From 597412abcc8aa4dee671d1d7f37f68d6086cb33c Mon Sep 17 00:00:00 2001 From: Sayamame-beans <61457993+Sayamame-beans@users.noreply.github.com> Date: Tue, 19 Nov 2024 13:11:33 +0000 Subject: [PATCH 10/11] fix(backend): incorrect typing with query --- packages/backend/src/core/QueryService.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/core/QueryService.ts b/packages/backend/src/core/QueryService.ts index 1d78a991fc..d9d63a8a0b 100644 --- a/packages/backend/src/core/QueryService.ts +++ b/packages/backend/src/core/QueryService.ts @@ -132,8 +132,13 @@ export class QueryService { .select('muting.muteeId') .where('muting.muterId = :muterId', { muterId: me.id }); + const mutingArrayQuery = this.mutingsRepository.createQueryBuilder('muting') + .select('array_agg(muting.muteeId)', 'muting.muteeIdArray') + .where('muting.muterId = :muterId', { muterId: me.id }); + if (exclude) { mutingQuery.andWhere('muting.muteeId != :excludeId', { excludeId: exclude.id }); + mutingArrayQuery.andWhere('muting.muteeId != :excludeId', { excludeId: exclude.id }); } const mutingInstanceQuery = this.userProfilesRepository.createQueryBuilder('user_profile') @@ -177,11 +182,12 @@ export class QueryService { q.andWhere(new Brackets(qb => { qb .where('note.mentions IS NULL') - .orWhere(`NOT (note.mentions && (${ mutingQuery.getQuery() }))`); + .orWhere(`NOT (note.mentions && (${ mutingArrayQuery.getQuery() }))`); })); } q.setParameters(mutingQuery.getParameters()); + q.setParameters(mutingArrayQuery.getParameters()); q.setParameters(mutingInstanceQuery.getParameters()); } From b8926866f71c9079aeda779c40a4c177c23b5a2a Mon Sep 17 00:00:00 2001 From: Sayamame-beans <61457993+Sayamame-beans@users.noreply.github.com> Date: Thu, 21 Nov 2024 13:17:43 +0000 Subject: [PATCH 11/11] fix(backend): lack of muting empty check --- packages/backend/src/core/QueryService.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/core/QueryService.ts b/packages/backend/src/core/QueryService.ts index d9d63a8a0b..5794b15445 100644 --- a/packages/backend/src/core/QueryService.ts +++ b/packages/backend/src/core/QueryService.ts @@ -127,7 +127,7 @@ export class QueryService { } @bindThis - public generateMutedUserQuery(q: SelectQueryBuilder, me: { id: MiUser['id'] }, exclude?: { id: MiUser['id'] }, checkMentions: boolean = true): void { + public generateMutedUserQuery(q: SelectQueryBuilder, me: { id: MiUser['id'] }, exclude?: { id: MiUser['id'] }, checkMentions = true): void { const mutingQuery = this.mutingsRepository.createQueryBuilder('muting') .select('muting.muteeId') .where('muting.muterId = :muterId', { muterId: me.id }); @@ -182,6 +182,7 @@ export class QueryService { q.andWhere(new Brackets(qb => { qb .where('note.mentions IS NULL') + .orWhere(`NOT EXISTS (${ mutingQuery.getQuery() })`) .orWhere(`NOT (note.mentions && (${ mutingArrayQuery.getQuery() }))`); })); }