From fd9b7edeff0f289b5ab21654a23bae0049291e60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B4=87=E5=B3=B0=20=E6=9C=94=E8=8F=AF?= Date: Tue, 19 Nov 2024 11:08:34 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E3=82=AF=E3=82=A8=E3=83=AA=E3=81=A8?= =?UTF-8?q?=E3=81=8B=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/backend/src/core/QueryService.ts | 5 +++-- packages/backend/src/core/entities/UserEntityService.ts | 8 ++++---- .../server/api/endpoints/blocking-reaction-user/list.ts | 3 ++- .../backend/src/server/api/endpoints/blocking/list.ts | 3 ++- packages/backend/test/unit/entities/UserEntityService.ts | 6 +++--- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/packages/backend/src/core/QueryService.ts b/packages/backend/src/core/QueryService.ts index 65b6bc2ef4..8cdfb20bb9 100644 --- a/packages/backend/src/core/QueryService.ts +++ b/packages/backend/src/core/QueryService.ts @@ -11,6 +11,7 @@ import type { UserProfilesRepository, FollowingsRepository, ChannelFollowingsRep import { bindThis } from '@/decorators.js'; import { IdService } from '@/core/IdService.js'; import type { SelectQueryBuilder } from 'typeorm'; +import {MiBlockingType} from "@/models/_.js"; @Injectable() export class QueryService { @@ -73,7 +74,7 @@ export class QueryService { const blockingQuery = this.blockingsRepository.createQueryBuilder('blocking') .select('blocking.blockerId') .where('blocking.blockeeId = :blockeeId', { blockeeId: me.id }) - .andWhere('blocking.blockType = "user"'); + .andWhere('blocking.blockType = :blockType', { blockType: MiBlockingType.User }); // 投稿の作者にブロックされていない かつ // 投稿の返信先の作者にブロックされていない かつ @@ -99,7 +100,7 @@ export class QueryService { const blockingQuery = this.blockingsRepository.createQueryBuilder('blocking') .select('blocking.blockeeId') .where('blocking.blockerId = :blockerId', { blockerId: me.id }) - .andWhere('blocking.blockType = "user"'); + .andWhere('blocking.blockType = :blockType', { blockType: MiBlockingType.User }); const blockedQuery = this.blockingsRepository.createQueryBuilder('blocking') .select('blocking.blockerId') diff --git a/packages/backend/src/core/entities/UserEntityService.ts b/packages/backend/src/core/entities/UserEntityService.ts index c61587c595..df2c803691 100644 --- a/packages/backend/src/core/entities/UserEntityService.ts +++ b/packages/backend/src/core/entities/UserEntityService.ts @@ -291,25 +291,25 @@ export class UserEntityService implements OnModuleInit { this.blockingsRepository.createQueryBuilder('b') .select('b.blockeeId') .where('b.blockerId = :me', { me }) - .andWhere('b.blockType = "user"') + .andWhere('b.blockType = :type', { type: MiBlockingType.User }) .getRawMany<{ b_blockeeId: string }>() .then(it => it.map(it => it.b_blockeeId)), this.blockingsRepository.createQueryBuilder('b') .select('b.blockerId') .where('b.blockeeId = :me', { me }) - .andWhere('b.blockType = "user"') + .andWhere('b.blockType = :type', { type: MiBlockingType.User }) .getRawMany<{ b_blockerId: string }>() .then(it => it.map(it => it.b_blockerId)), this.blockingsRepository.createQueryBuilder('b') .select('b.blockeeId') .where('b.blockerId = :me', { me }) - .andWhere('b.blockType = "reaction"') + .andWhere('b.blockType = :type', { type: MiBlockingType.Reaction }) .getRawMany<{ b_blockeeId: string }>() .then(it => it.map(it => it.b_blockeeId)), this.blockingsRepository.createQueryBuilder('b') .select('b.blockerId') .where('b.blockeeId = :me', { me }) - .andWhere('b.blockType = "reaction"') + .andWhere('b.blockType = :type', { type: MiBlockingType.Reaction }) .getRawMany<{ b_blockerId: string }>() .then(it => it.map(it => it.b_blockerId)), this.mutingsRepository.createQueryBuilder('m') diff --git a/packages/backend/src/server/api/endpoints/blocking-reaction-user/list.ts b/packages/backend/src/server/api/endpoints/blocking-reaction-user/list.ts index 5055bd596b..f4cb38ec1e 100644 --- a/packages/backend/src/server/api/endpoints/blocking-reaction-user/list.ts +++ b/packages/backend/src/server/api/endpoints/blocking-reaction-user/list.ts @@ -9,6 +9,7 @@ import type { BlockingsRepository } from '@/models/_.js'; import { QueryService } from '@/core/QueryService.js'; import { BlockingEntityService } from '@/core/entities/BlockingEntityService.js'; import { DI } from '@/di-symbols.js'; +import { MiBlockingType } from '@/models/Blocking.js'; export const meta = { tags: ['account'], @@ -50,7 +51,7 @@ export default class extends Endpoint { // eslint- super(meta, paramDef, async (ps, me) => { const query = this.queryService.makePaginationQuery(this.blockingsRepository.createQueryBuilder('blocking'), ps.sinceId, ps.untilId) .andWhere('blocking.blockerId = :meId', { meId: me.id }) - .andWhere('blocking.blockType = "reaction"'); + .andWhere('blocking.blockType = :blockType', { blockType: MiBlockingType.Reaction }); const blockings = await query .limit(ps.limit) diff --git a/packages/backend/src/server/api/endpoints/blocking/list.ts b/packages/backend/src/server/api/endpoints/blocking/list.ts index f7a5fa1412..292bc0417e 100644 --- a/packages/backend/src/server/api/endpoints/blocking/list.ts +++ b/packages/backend/src/server/api/endpoints/blocking/list.ts @@ -9,6 +9,7 @@ import type { BlockingsRepository } from '@/models/_.js'; import { QueryService } from '@/core/QueryService.js'; import { BlockingEntityService } from '@/core/entities/BlockingEntityService.js'; import { DI } from '@/di-symbols.js'; +import { MiBlockingType } from '@/models/Blocking.js'; export const meta = { tags: ['account'], @@ -50,7 +51,7 @@ export default class extends Endpoint { // eslint- super(meta, paramDef, async (ps, me) => { const query = this.queryService.makePaginationQuery(this.blockingsRepository.createQueryBuilder('blocking'), ps.sinceId, ps.untilId) .andWhere('blocking.blockerId = :meId', { meId: me.id }) - .andWhere('blocking.blockType = "user"'); + .andWhere('blocking.blockType = :blockType', { blockType: MiBlockingType.User }); const blockings = await query .limit(ps.limit) diff --git a/packages/backend/test/unit/entities/UserEntityService.ts b/packages/backend/test/unit/entities/UserEntityService.ts index b28d386b43..c5c69cdb74 100644 --- a/packages/backend/test/unit/entities/UserEntityService.ts +++ b/packages/backend/test/unit/entities/UserEntityService.ts @@ -12,7 +12,7 @@ import { secureRndstr } from '@/misc/secure-rndstr.js'; import { genAidx } from '@/misc/id/aidx.js'; import { BlockingsRepository, - FollowingsRepository, FollowRequestsRepository, + FollowingsRepository, FollowRequestsRepository, MiBlockingType, MiUserProfile, MutingsRepository, RenoteMutingsRepository, UserMemoRepository, UserProfilesRepository, @@ -115,7 +115,7 @@ describe('UserEntityService', () => { id: genAidx(Date.now()), blockerId: blocker.id, blockeeId: blockee.id, - isReactionBlock: false, + blockType: MiBlockingType.User, }); } @@ -124,7 +124,7 @@ describe('UserEntityService', () => { id: genAidx(Date.now()), blockerId: blocker.id, blockeeId: blockee.id, - isReactionBlock: true, + blockType: MiBlockingType.Reaction, }); }