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; }