@@ -61,15 +61,15 @@ public List<OneToOneChatRoomResDto> getOneToOneRooms() {
6161 PartyParticipant partyParticipant = partyParticipantRepository .findByOneToOneChatRoom (chatRoom ).orElseThrow ();
6262 ParticipantStatus status = partyParticipant .getStatus ();
6363
64- // (chatRoom, user)로 채팅참여 엔티티 조회
64+ User targetUser = partyParticipant . getUser ();
6565 ChatRoomMember chatRoomMember = chatRoomMemberRepository .findByChatRoomAndUser (chatRoom , user ).orElseThrow ();
6666
6767 // 마지막으로 읽은 시점을 기점으로 몇 개의 메시지가 안 읽혔는지 확인
6868 long unreadCnt = chatMessageRepository .countByChatRoomIdAndCreatedAtAfterAndSenderIdNot (chatRoom .getId (), chatRoomMember .getLastReadAt (), user .getUserId ());
6969
7070 String content = recentMessage != null ? recentMessage .getContent () : "" ;
7171 // dto로 합침
72- return OneToOneChatRoomResDto .of (chatRoom , user , chatRoom . getParticipants (). get ( 0 ). getUser () , content , timeAgo , status , unreadCnt );
72+ return OneToOneChatRoomResDto .of (chatRoom , user , targetUser , content , timeAgo , status , unreadCnt );
7373 })
7474 .toList ();
7575 }
@@ -107,8 +107,7 @@ public OneToOneChatRoomDetailResDto getOneToOneRoom(Long chatRoomId) {
107107 if (!chatRoom .getType ().equals (ChatRoomType .ONE_TO_ONE )) throw BusinessException .of (ChatRoomErrorCode .NOT_ONE_TO_ONE );
108108
109109 PartyParticipant partyParticipant = partyParticipantRepository .findByOneToOneChatRoomAndStatus (chatRoom , ParticipantStatus .PENDING );
110-
111- ChatRoomMember participant = chatRoom .getParticipants ().stream ().findFirst ().get ();
110+ User participant = partyParticipant .getUser ();
112111
113112 ChatRoom groupChatRoom = chatRoomRepository .findByPartyAndType (chatRoom .getParty (), ChatRoomType .GROUP ).orElseGet (null );
114113 return OneToOneChatRoomDetailResDto .of (chatRoom .getParty (), partyParticipant , currentUser , groupChatRoom , participant );
0 commit comments