Skip to content

Commit 687ca98

Browse files
authored
Merge pull request #306 from Coffect/feat/profile_add
refactor : 메시지 읽음 오류
2 parents 876bdc9 + b72225c commit 687ca98

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

src/chat/chat.Controller.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export class ChatController extends Controller {
5959
public async makeChatRoom(
6060
@Request() req: ExpressRequest,
6161
@Body()
62-
body: {
62+
body: {
6363
userId: number;
6464
}
6565
): Promise<ITsoaSuccessResponse<{ chatRoomId: string }>> {
@@ -187,8 +187,8 @@ export class ChatController extends Controller {
187187
): Promise<ITsoaSuccessResponse<string>> {
188188
const userId = req.user.index;
189189
const chatRoomId = body.chatRoomId;
190-
await this.chatService.readMessage(chatRoomId, userId);
191-
return new TsoaSuccessResponse<string>('메시지 읽음 처리 성공');
190+
const message = await this.chatService.readMessage(chatRoomId, userId);
191+
return new TsoaSuccessResponse<string>(message);
192192
}
193193

194194
/**

src/chat/chat.Service.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,14 @@ export class ChatService {
106106
chatRoomId: string,
107107
userId: number
108108
): Promise<string> {
109+
const chatRoom = await this.chatModel.getChatRoom(userId);
110+
if (!chatRoom.some((room) => room.chatroomId === chatRoomId)) {
111+
throw new ChatRoomNotFound(chatRoomId);
112+
}
109113
const result = await this.chatModel.readMessage(chatRoomId, userId);
110114

111115
if (!result) {
112-
throw new ChatRoomNotFound(chatRoomId);
116+
return '읽을 채팅이 없습니다.';
113117
}
114118

115119
return '채팅 읽기 성공';

0 commit comments

Comments
 (0)