Skip to content

Commit

Permalink
feat(채팅): 채팅 발송 성공 시 채팅객체반환
Browse files Browse the repository at this point in the history
  • Loading branch information
jsween5723 committed Dec 22, 2023
1 parent 7b4308c commit 5548f8e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/room/room.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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 },
) {
Expand All @@ -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')
Expand Down
1 change: 1 addition & 0 deletions src/room/room.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 5548f8e

Please sign in to comment.