Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/chat/repository/chatroom.repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 7 additions & 1 deletion src/chat/service/chatroom.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,20 @@ export const ChatroomService = {
}

// 채팅방 중복 확인
const existing = await ChatroomRepository.findChatroomByUsersAndCommission(
let existing = await ChatroomRepository.findChatroomByUsersAndCommission(
dto.userId,
dto.artistId,
dto.commissionId
);

// 기존 채팅방 반환
if (existing) {
if (existing.hiddenUser || existing.hiddenArtist) {
existing = await ChatroomRepository.reactivateChatroom(existing.id, {
hiddenUser: false,
hiddenArtist: false,
});
}
return existing;
}

Expand Down