From 5548f8e7ea830bec3e48f9cb3f3d34ca3d228473 Mon Sep 17 00:00:00 2001 From: jsween5723 Date: Sat, 23 Dec 2023 04:16:15 +0900 Subject: [PATCH] =?UTF-8?q?feat(=EC=B1=84=ED=8C=85):=20=EC=B1=84=ED=8C=85?= =?UTF-8?q?=20=EB=B0=9C=EC=86=A1=20=EC=84=B1=EA=B3=B5=20=EC=8B=9C=20?= =?UTF-8?q?=EC=B1=84=ED=8C=85=EA=B0=9D=EC=B2=B4=EB=B0=98=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/room/room.controller.ts | 8 +++----- src/room/room.service.ts | 1 + 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/room/room.controller.ts b/src/room/room.controller.ts index 121f074..bcb6339 100644 --- a/src/room/room.controller.ts +++ b/src/room/room.controller.ts @@ -14,8 +14,6 @@ import { RoomDetailDto, RoomDto } from './dto/room.dto'; import { ApiBody, ApiResponse, OmitType } from '@nestjs/swagger'; import { ChatDto } from './dto/chat.dto'; import { Message } from '../chat/schema/chat.schema'; -import { find } from 'rxjs'; -import { request } from 'express'; import { JwtAuthGuard } from '../jwt/jwt.guard'; import { BaseResponse } from '../common/base-response'; @@ -63,7 +61,7 @@ export class RoomController { @ApiBody({ type: Message }) @UseGuards(JwtAuthGuard) public async sendMessage( - @Req() request: Request & { user: { id: string } }, + @Req() request, @Param('id') roomId: string, @Body() dto: { message: string }, ) { @@ -73,12 +71,12 @@ export class RoomController { message: '로그인이 필요합니다.', }); } - await this.service.sendChat({ + const chat = await this.service.sendChat({ ...dto, roomId, senderId: request.user.id, }); - return new BaseResponse(true); + return new BaseResponse(new ChatDto(chat)); } @Get(':id/chats') diff --git a/src/room/room.service.ts b/src/room/room.service.ts index 830e402..3456901 100644 --- a/src/room/room.service.ts +++ b/src/room/room.service.ts @@ -128,6 +128,7 @@ export class RoomService { this.roomGateway.io .in(users.map((user) => user.id)) .emit('last-chat-append', createdChat); + return createdChat; } public async searchChat(roomId: string) {