Skip to content

Commit

Permalink
Merge pull request #99 from sublinks/issue/98
Browse files Browse the repository at this point in the history
#98 fixed comment list action
  • Loading branch information
jgrim authored Dec 19, 2023
2 parents c841e88 + 34ae564 commit 8c4aba7
Showing 1 changed file with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -298,21 +297,21 @@ GetCommentsResponse list(@Valid final GetComments getCommentsForm, final JwtPers
.builder().listingType(listingType).commentSortType(sortType);

if (post_id.isPresent()) {
final Optional<Post> 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> 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));

Expand Down

0 comments on commit 8c4aba7

Please sign in to comment.