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] 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);