Skip to content

Commit

Permalink
fix(채팅): DTO 오류 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
jsween5723 committed Jan 12, 2024
1 parent 48a074a commit ce23363
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/room/dto/chat.dto.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
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';

export class ChatDto {
@ApiProperty()
id: string;
@ApiProperty({ type: () => PickType(RoomDto, ['id'] as const) })
room: Pick<RoomDto, 'id'>;
@ApiProperty()
room: { id: string };
@ApiProperty({ type: () => PickType(User, ['id'] as const) })
sender: Pick<User, 'id'>;
@ApiProperty({ type: () => Message })
Expand Down
7 changes: 3 additions & 4 deletions src/room/room.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
}

Expand Down

0 comments on commit ce23363

Please sign in to comment.