From 34ae5647eea5cb5a1624332bc049b0e25b6e0656 Mon Sep 17 00:00:00 2001 From: Jason Grim Date: Mon, 18 Dec 2023 20:41:48 -0500 Subject: [PATCH] #98 fixed comment list action --- .../controllers/CommentController.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/sublinks/sublinksapi/api/lemmy/v3/comment/controllers/CommentController.java b/src/main/java/com/sublinks/sublinksapi/api/lemmy/v3/comment/controllers/CommentController.java index 5e103a01..ee0a02d1 100644 --- a/src/main/java/com/sublinks/sublinksapi/api/lemmy/v3/comment/controllers/CommentController.java +++ b/src/main/java/com/sublinks/sublinksapi/api/lemmy/v3/comment/controllers/CommentController.java @@ -52,7 +52,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; -import lombok.Builder; import lombok.RequiredArgsConstructor; import org.springframework.core.convert.ConversionService; import org.springframework.http.HttpStatus; @@ -298,21 +297,21 @@ GetCommentsResponse list(@Valid final GetComments getCommentsForm, final JwtPers .builder().listingType(listingType).commentSortType(sortType); if (post_id.isPresent()) { - final Optional post = postRepository.findById((long) post_id.get()); - if (post.isPresent()) { - searchBuilder.post(post.get()); - } else { - throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "post_not_found"); - } + final Optional post = postRepository.findById((long) post_id.get()); + if (post.isPresent()) { + searchBuilder.post(post.get()); + } else { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "post_not_found"); + } } - if (perPage.isPresent() && perPage.get() < 1 || perPage.get() > 50) { - throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "couldnt_get_comments"); + if (perPage.isPresent() && (perPage.get() < 1 || perPage.get() > 50)) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "couldnt_get_comments"); } searchBuilder.perPage(perPage.orElse(10)); if (page.isPresent() && page.get() < 1) { - throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "couldnt_get_comments"); + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "couldnt_get_comments"); } searchBuilder.page(page.orElse(1));