Change 404 to 200 if no comment/vote/follow on article

This commit is contained in:
2020-03-20 02:11:56 +01:00
parent c55eba4219
commit ddea05aea0
3 changed files with 10 additions and 5 deletions

View File

@@ -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<FollowArticlePaths.CitizenFollowArticleRequest> {
val follows = repo.findByCitizen(it.citizen)
assertCan(VIEW, follows.result)
if (follows.result.isNotEmpty()) {
assertCan(VIEW, follows.result)
}
call.respond(follows)
}
}