From d71258d79ba9ea15b7070d94ec7118d77269e6cc Mon Sep 17 00:00:00 2001 From: bkw535 Date: Thu, 21 Aug 2025 23:08:13 +0900 Subject: [PATCH] =?UTF-8?q?[REFACTOR]=20=EC=B1=84=ED=8C=85=EB=B0=A9=20?= =?UTF-8?q?=EC=9E=AC=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/chat/repository/chatroom.repository.js | 7 +++++++ src/chat/service/chatroom.service.js | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/chat/repository/chatroom.repository.js b/src/chat/repository/chatroom.repository.js index 3b07342..c96353a 100644 --- a/src/chat/repository/chatroom.repository.js +++ b/src/chat/repository/chatroom.repository.js @@ -22,6 +22,13 @@ export const ChatroomRepository = { }); }, + async reactivateChatroom(chatroomId, updateData) { + return await prisma.chatroom.update({ + where: { id: chatroomId }, + data: updateData, + }); + }, + async findChatroomsByUser(account) { // 1. 채팅방 기본 정보 + 마지막 메시지(내용, 생성시간, id) 조회 let chatrooms; diff --git a/src/chat/service/chatroom.service.js b/src/chat/service/chatroom.service.js index 961444b..9f70ecf 100644 --- a/src/chat/service/chatroom.service.js +++ b/src/chat/service/chatroom.service.js @@ -26,7 +26,7 @@ export const ChatroomService = { } // 채팅방 중복 확인 - const existing = await ChatroomRepository.findChatroomByUsersAndCommission( + let existing = await ChatroomRepository.findChatroomByUsersAndCommission( dto.userId, dto.artistId, dto.commissionId @@ -34,6 +34,12 @@ export const ChatroomService = { // 기존 채팅방 반환 if (existing) { + if (existing.hiddenUser || existing.hiddenArtist) { + existing = await ChatroomRepository.reactivateChatroom(existing.id, { + hiddenUser: false, + hiddenArtist: false, + }); + } return existing; }