diff --git a/src/main/kotlin/fr/dcproject/routes/CommentArticle.kt b/src/main/kotlin/fr/dcproject/routes/CommentArticle.kt index 6a34afd..a5c33b2 100644 --- a/src/main/kotlin/fr/dcproject/routes/CommentArticle.kt +++ b/src/main/kotlin/fr/dcproject/routes/CommentArticle.kt @@ -43,7 +43,9 @@ object CommentArticlePaths { fun Route.commentArticle(repo: CommentArticleRepository) { get { val comment = repo.findByTarget(it.article, it.page, it.limit, it.sort) - assertCan(VIEW, comment.result) + if (comment.result.isNotEmpty()) { + assertCan(VIEW, comment.result) + } call.respond(HttpStatusCode.OK, comment) } diff --git a/src/main/kotlin/fr/dcproject/routes/FollowArticle.kt b/src/main/kotlin/fr/dcproject/routes/FollowArticle.kt index cb0f2c5..d829959 100644 --- a/src/main/kotlin/fr/dcproject/routes/FollowArticle.kt +++ b/src/main/kotlin/fr/dcproject/routes/FollowArticle.kt @@ -42,12 +42,14 @@ fun Route.followArticle(repo: FollowArticleRepository) { repo.findFollow(citizen, it.article)?.let { follow -> assertCan(VIEW, follow) call.respond(follow) - } ?: call.respond(HttpStatusCode.NotFound) + } ?: call.respond(HttpStatusCode.NoContent) } get { val follows = repo.findByCitizen(it.citizen) - assertCan(VIEW, follows.result) + if (follows.result.isNotEmpty()) { + assertCan(VIEW, follows.result) + } call.respond(follows) } } \ No newline at end of file diff --git a/src/main/kotlin/fr/dcproject/routes/VoteArticle.kt b/src/main/kotlin/fr/dcproject/routes/VoteArticle.kt index 5b35998..dd67019 100644 --- a/src/main/kotlin/fr/dcproject/routes/VoteArticle.kt +++ b/src/main/kotlin/fr/dcproject/routes/VoteArticle.kt @@ -86,8 +86,9 @@ fun Route.voteArticle(repo: VoteArticleRepository, voteCommentRepo: VoteComment, get { val votes = repo.findCitizenVotesByTargets(it.citizen, it.id) - assertCan(VIEW, votes) - + if (votes.isNotEmpty()) { + assertCan(VIEW, votes) + } call.respond(votes) } } \ No newline at end of file