diff --git a/src/room/dto/chat.dto.ts b/src/room/dto/chat.dto.ts index ba3fb4c..d19f1c8 100644 --- a/src/room/dto/chat.dto.ts +++ b/src/room/dto/chat.dto.ts @@ -1,5 +1,4 @@ import { ApiProperty, PickType } from '@nestjs/swagger'; -import { RoomDto } from './room.dto'; import { User } from '../../user/schema/user.schema'; import { Chat, Message } from '../../chat/schema/chat.schema'; import * as moment from 'moment-timezone'; @@ -7,8 +6,8 @@ import * as moment from 'moment-timezone'; export class ChatDto { @ApiProperty() id: string; - @ApiProperty({ type: () => PickType(RoomDto, ['id'] as const) }) - room: Pick; + @ApiProperty() + room: { id: string }; @ApiProperty({ type: () => PickType(User, ['id'] as const) }) sender: Pick; @ApiProperty({ type: () => Message }) diff --git a/src/room/room.service.ts b/src/room/room.service.ts index cf0dc65..d40e1c9 100644 --- a/src/room/room.service.ts +++ b/src/room/room.service.ts @@ -116,12 +116,11 @@ export class RoomService { { _id: room._id }, { $set: { lastChat: createdChat } }, ); - console.log(createdChat); - console.log(chat.roomId); + const result = new ChatDto(createdChat); this.detailGateway.io.server .of(`/chat-rooms/${chat.roomId}`) .to(chat.roomId) - .emit('chat-append', new ChatDto(createdChat)); + .emit('chat-append', result); const sockets = await this.detailGateway.io.server .of(`/chat-rooms/${chat.roomId}`) .in(chat.roomId) @@ -134,7 +133,7 @@ export class RoomService { this.roomGateway.io.server .of('/chat-rooms') .to(users.map((user) => user.id)) - .emit('last-chat-append', new ChatDto(createdChat)); + .emit('last-chat-append', result); return createdChat; }