Skip to content

Commit bd39a7b

Browse files
authored
Merge pull request #130 from kjiyun/chat
#129 Fix: 채팅 조회 가능범위 변경
2 parents e0d650f + 571ee2c commit bd39a7b

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/main/java/com/memesphere/domain/chat/controller/ChatController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public ChatResponse chat(@DestinationVariable("coin_id") Long coin_id,
3939
public ApiResponse<Page<ChatResponse>> getChatList(@PathVariable("coin_id") Long coin_id,
4040
Pageable pageable,
4141
@AuthenticationPrincipal CustomUserDetails customUserDetails) {
42-
User user = customUserDetails.getUser();
42+
User user = (customUserDetails != null) ? customUserDetails.getUser() : null;
4343

4444
return ApiResponse.onSuccess(chatService.getChatList(coin_id, pageable, user));
4545
}

src/main/java/com/memesphere/domain/chat/converter/ChatConverter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ public static Chat toChat(MemeCoin memeCoin, ChatRequest chatRequest, User user)
2222
}
2323

2424
public static ChatResponse toChatResponse(Chat chat, User user) {
25-
boolean isLiked = chat.getChatLikeList().stream()
25+
boolean isLiked = user != null && chat.getChatLikeList().stream()
2626
.anyMatch(chatLike -> Objects.equals(chatLike.getUser().getId(), user.getId()));
2727

28-
if (chat.getChatLikeList().isEmpty()) {}
2928
return ChatResponse.builder()
3029
.id(chat.getId())
3130
.message(chat.getMessage())

0 commit comments

Comments
 (0)