From 225db6859db8b05d0de871d863e0507772d09917 Mon Sep 17 00:00:00 2001 From: Nho Quy Dinh Date: Fri, 27 Dec 2024 12:36:29 +0100 Subject: [PATCH] Update UserDto.java --- src/main/java/com/nonononoki/alovoa/model/UserDto.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/nonononoki/alovoa/model/UserDto.java b/src/main/java/com/nonononoki/alovoa/model/UserDto.java index ff1dd9b8..e26927eb 100644 --- a/src/main/java/com/nonononoki/alovoa/model/UserDto.java +++ b/src/main/java/com/nonononoki/alovoa/model/UserDto.java @@ -175,9 +175,13 @@ public static UserDto userToUserDto(DtoBuilder builder) .anyMatch(o -> Objects.equals(o.getUserTo().getId(), user.getId())); } if (user.getLikes() != null) { - dto.likesCurrentUser = user.getLikes().stream() - .filter(o -> o.getUserTo() != null) - .anyMatch(o -> Objects.equals(o.getUserTo().getId(), currentUser.getId())); + try { + dto.likesCurrentUser = user.getLikes().stream() + .filter(o -> o.getUserTo() != null) + .anyMatch(o -> Objects.equals(o.getUserTo().getId(), currentUser.getId())); + } catch (Exception ignored) { + dto.likesCurrentUser = false; + } } if (currentUser.getLikes() != null) { dto.likedByCurrentUser = currentUser.getLikes().stream()