From 2fa6faae28cdd8877048b7ffcc2174c57c0cc1ae Mon Sep 17 00:00:00 2001 From: leemhoon00 Date: Fri, 5 Dec 2025 09:54:09 +0900 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20GET=20/chats/id/user=EC=97=90?= =?UTF-8?q?=EC=84=9C=20isBlocked=EA=B0=80=20=EB=B0=98=EB=8C=80=EB=A1=9C=20?= =?UTF-8?q?=EB=90=98=EC=96=B4=EC=9E=88=EB=8A=94=20=EB=B2=84=EA=B7=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/module/chat/repository/chat.reader.ts | 4 ++-- test/e2e/chat/get-opponent-user.e2e-spec.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/module/chat/repository/chat.reader.ts b/src/module/chat/repository/chat.reader.ts index d5481a2..3b06658 100644 --- a/src/module/chat/repository/chat.reader.ts +++ b/src/module/chat/repository/chat.reader.ts @@ -98,8 +98,8 @@ export class ChatReader { .fn('EXISTS', [ eb .selectFrom('Block') - .where('Block.blockerId', '=', kyselyUuid(userId)) - .whereRef('Block.blockingId', '=', 'User.id'), + .where('Block.blockingId', '=', kyselyUuid(userId)) + .whereRef('Block.blockerId', '=', 'User.id'), ]) .as('isBlocked'), ) diff --git a/test/e2e/chat/get-opponent-user.e2e-spec.ts b/test/e2e/chat/get-opponent-user.e2e-spec.ts index fa7a600..b0c8bf8 100644 --- a/test/e2e/chat/get-opponent-user.e2e-spec.ts +++ b/test/e2e/chat/get-opponent-user.e2e-spec.ts @@ -130,8 +130,8 @@ describe('GET /chats/:id/user - 상대유저 조회', () => { await prisma.block.create({ data: { - blockerId: me.id, - blockingId: targetUser.id, + blockingId: me.id, + blockerId: targetUser.id, }, }); From 85784561ce6f73e8bb40adf119e789a38cd3a351 Mon Sep 17 00:00:00 2001 From: leemhoon00 Date: Fri, 5 Dec 2025 10:03:52 +0900 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=EC=83=81=EB=8C=80=EC=9C=A0?= =?UTF-8?q?=EC=A0=80=20=EC=A1=B0=ED=9A=8C=EC=97=90=20isBlocking=EB=8F=84?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/module/chat/chat.controller.ts | 6 +++--- src/module/chat/dto/chat.response.ts | 8 ++++++++ src/module/chat/repository/chat.reader.ts | 11 +++++++++++ test/e2e/chat/get-opponent-user.e2e-spec.ts | 8 ++++++++ 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/module/chat/chat.controller.ts b/src/module/chat/chat.controller.ts index eb8cf64..464531f 100644 --- a/src/module/chat/chat.controller.ts +++ b/src/module/chat/chat.controller.ts @@ -28,7 +28,7 @@ import { JwtGuard } from 'src/core/guard'; import { CurrentUser } from 'src/core/decorator'; import { ChatService } from './chat.service'; import { IdResponse } from 'src/shared/response'; -import { ChatsResponse } from './dto/chat.response'; +import { ChatsResponse, OpponentUserResponse } from './dto/chat.response'; import { UserBaseResponse, UserBaseWithBlockedResponse } from '../user/dto'; @ApiTags('/chats') @@ -93,12 +93,12 @@ export class ChatController { } @ApiOperation({ summary: '상대 유저 조회' }) - @ApiResponse({ status: 200, type: UserBaseWithBlockedResponse }) + @ApiResponse({ status: 200, type: OpponentUserResponse }) @Get(':id/user') async getOpponentUser( @CurrentUser() userId: string, @Param('id', new ParseUUIDPipe()) chatId: string, - ): Promise { + ): Promise { return await this.chatService.getOpponentUser(userId, chatId); } diff --git a/src/module/chat/dto/chat.response.ts b/src/module/chat/dto/chat.response.ts index 47af0bf..a5789a7 100644 --- a/src/module/chat/dto/chat.response.ts +++ b/src/module/chat/dto/chat.response.ts @@ -38,3 +38,11 @@ export class ChatsResponse extends CursorResponse { @ApiProperty({ type: ChatResponse, isArray: true }) chats: ChatResponse[]; } + +export class OpponentUserResponse extends UserBaseResponse { + @ApiProperty() + isBlocked: boolean; + + @ApiProperty() + isBlocking: boolean; +} diff --git a/src/module/chat/repository/chat.reader.ts b/src/module/chat/repository/chat.reader.ts index 3b06658..89fee9e 100644 --- a/src/module/chat/repository/chat.reader.ts +++ b/src/module/chat/repository/chat.reader.ts @@ -103,6 +103,16 @@ export class ChatReader { ]) .as('isBlocked'), ) + .select((eb) => + eb + .fn('EXISTS', [ + eb + .selectFrom('Block') + .where('Block.blockerId', '=', kyselyUuid(userId)) + .whereRef('Block.blockingId', '=', 'User.id'), + ]) + .as('isBlocking'), + ) .executeTakeFirst(); if (!result) return null; @@ -112,6 +122,7 @@ export class ChatReader { image: result.image, url: result.url, isBlocked: result.isBlocked, + isBlocking: result.isBlocking, }; } diff --git a/test/e2e/chat/get-opponent-user.e2e-spec.ts b/test/e2e/chat/get-opponent-user.e2e-spec.ts index b0c8bf8..8a083c5 100644 --- a/test/e2e/chat/get-opponent-user.e2e-spec.ts +++ b/test/e2e/chat/get-opponent-user.e2e-spec.ts @@ -135,6 +135,13 @@ describe('GET /chats/:id/user - 상대유저 조회', () => { }, }); + await prisma.block.create({ + data: { + blockerId: me.id, + blockingId: targetUser.id, + }, + }); + // when const { status, body } = await request(app.getHttpServer()) .get(`/chats/${chat.id}/user`) @@ -145,5 +152,6 @@ describe('GET /chats/:id/user - 상대유저 조회', () => { expect(status).toBe(200); expect(body.id).toBe(targetUser.id); expect(body.isBlocked).toBe(true); + expect(body.isBlocking).toBe(true); }); }); From decb362e64450a21e867c55ceccf4d74dd2e9e44 Mon Sep 17 00:00:00 2001 From: leemhoon00 Date: Fri, 5 Dec 2025 10:05:08 +0900 Subject: [PATCH 3/3] dto@1.0.31 --- share/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/package.json b/share/package.json index d4c3658..376b4cf 100644 --- a/share/package.json +++ b/share/package.json @@ -1,6 +1,6 @@ { "name": "@grimity/dto", - "version": "1.0.30", + "version": "1.0.31", "types": "dist/share/index.d.ts", "exports": { ".": {