Change 404 to 200 if no comment/vote/follow on article
This commit is contained in:
@@ -43,7 +43,9 @@ object CommentArticlePaths {
|
|||||||
fun Route.commentArticle(repo: CommentArticleRepository) {
|
fun Route.commentArticle(repo: CommentArticleRepository) {
|
||||||
get<CommentArticlePaths.ArticleCommentRequest> {
|
get<CommentArticlePaths.ArticleCommentRequest> {
|
||||||
val comment = repo.findByTarget(it.article, it.page, it.limit, it.sort)
|
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)
|
call.respond(HttpStatusCode.OK, comment)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,12 +42,14 @@ fun Route.followArticle(repo: FollowArticleRepository) {
|
|||||||
repo.findFollow(citizen, it.article)?.let { follow ->
|
repo.findFollow(citizen, it.article)?.let { follow ->
|
||||||
assertCan(VIEW, follow)
|
assertCan(VIEW, follow)
|
||||||
call.respond(follow)
|
call.respond(follow)
|
||||||
} ?: call.respond(HttpStatusCode.NotFound)
|
} ?: call.respond(HttpStatusCode.NoContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
get<FollowArticlePaths.CitizenFollowArticleRequest> {
|
get<FollowArticlePaths.CitizenFollowArticleRequest> {
|
||||||
val follows = repo.findByCitizen(it.citizen)
|
val follows = repo.findByCitizen(it.citizen)
|
||||||
assertCan(VIEW, follows.result)
|
if (follows.result.isNotEmpty()) {
|
||||||
|
assertCan(VIEW, follows.result)
|
||||||
|
}
|
||||||
call.respond(follows)
|
call.respond(follows)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -86,8 +86,9 @@ fun Route.voteArticle(repo: VoteArticleRepository, voteCommentRepo: VoteComment,
|
|||||||
|
|
||||||
get<VoteArticlePaths.CitizenVotesByIdsRequest> {
|
get<VoteArticlePaths.CitizenVotesByIdsRequest> {
|
||||||
val votes = repo.findCitizenVotesByTargets(it.citizen, it.id)
|
val votes = repo.findCitizenVotesByTargets(it.citizen, it.id)
|
||||||
assertCan(VIEW, votes)
|
if (votes.isNotEmpty()) {
|
||||||
|
assertCan(VIEW, votes)
|
||||||
|
}
|
||||||
call.respond(votes)
|
call.respond(votes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user