Skip to content

Commit

Permalink
[fix] : 채팅 메시지 null일 때 NPE 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
hyun2371 committed Nov 16, 2024
1 parent 936c812 commit a6371c5
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/main/java/com/dnd/gongmuin/chatroom/dto/ChatRoomMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ public static ChatRoomSimpleResponse toChatRoomSimpleResponse(
ChatRoomInfo chatRoomInfo,
LatestChatMessage latestChatMessage
) {
String content = null;
String type = null;
String createdAt = null;

if (latestChatMessage != null) {
content = latestChatMessage.content();
type = latestChatMessage.type();
createdAt = latestChatMessage.createdAt().toString();
}

return new ChatRoomSimpleResponse(
chatRoomInfo.chatRoomId(),
new MemberInfo(
Expand All @@ -59,9 +69,9 @@ public static ChatRoomSimpleResponse toChatRoomSimpleResponse(
chatRoomInfo.partnerJobGroup(),
chatRoomInfo.partnerProfileImageNo()
),
latestChatMessage.content(),
latestChatMessage.type(),
latestChatMessage.createdAt().toString()
content,
type,
createdAt
);
}
}

0 comments on commit a6371c5

Please sign in to comment.