diff --git a/src/main/java/com/dnd/gongmuin/chatroom/dto/ChatRoomMapper.java b/src/main/java/com/dnd/gongmuin/chatroom/dto/ChatRoomMapper.java index ffb21152..7f7eb957 100644 --- a/src/main/java/com/dnd/gongmuin/chatroom/dto/ChatRoomMapper.java +++ b/src/main/java/com/dnd/gongmuin/chatroom/dto/ChatRoomMapper.java @@ -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( @@ -59,9 +69,9 @@ public static ChatRoomSimpleResponse toChatRoomSimpleResponse( chatRoomInfo.partnerJobGroup(), chatRoomInfo.partnerProfileImageNo() ), - latestChatMessage.content(), - latestChatMessage.type(), - latestChatMessage.createdAt().toString() + content, + type, + createdAt ); } }