Skip to content

Commit cb2c219

Browse files
authored
Merge pull request #187 from umc-commit/refactor/186-chatroom-api
[REFACTOR] 채팅방 재생성
2 parents a6238df + d71258d commit cb2c219

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/chat/repository/chatroom.repository.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ export const ChatroomRepository = {
2222
});
2323
},
2424

25+
async reactivateChatroom(chatroomId, updateData) {
26+
return await prisma.chatroom.update({
27+
where: { id: chatroomId },
28+
data: updateData,
29+
});
30+
},
31+
2532
async findChatroomsByUser(account) {
2633
// 1. 채팅방 기본 정보 + 마지막 메시지(내용, 생성시간, id) 조회
2734
let chatrooms;

src/chat/service/chatroom.service.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,20 @@ export const ChatroomService = {
2626
}
2727

2828
// 채팅방 중복 확인
29-
const existing = await ChatroomRepository.findChatroomByUsersAndCommission(
29+
let existing = await ChatroomRepository.findChatroomByUsersAndCommission(
3030
dto.userId,
3131
dto.artistId,
3232
dto.commissionId
3333
);
3434

3535
// 기존 채팅방 반환
3636
if (existing) {
37+
if (existing.hiddenUser || existing.hiddenArtist) {
38+
existing = await ChatroomRepository.reactivateChatroom(existing.id, {
39+
hiddenUser: false,
40+
hiddenArtist: false,
41+
});
42+
}
3743
return existing;
3844
}
3945

0 commit comments

Comments
 (0)