docbrown/app/views/api/v0/comments/_comment.json.jbuilder
rhymes 21fca3e0f2
Comments API: hide deleted and hidden comments (plus docs) (#6482) [deploy]
* Modernize index test

* Hide comments body_html and user info if the comment is either deleted or hidden

* Shorten lines a bit

* Freeze repeated strings

* Document all /comments

* Document /comments/{id}
2020-03-07 09:02:10 +01:00

13 lines
378 B
Ruby

json.type_of "comment"
json.id_code comment.id_code_generated
if comment.deleted?
json.body_html "<p>#{Comment::TITLE_DELETED}</p>"
json.set! :user, {}
elsif comment.hidden_by_commentable_user?
json.body_html "<p>#{Comment::TITLE_HIDDEN}</p>"
json.set! :user, {}
else
json.body_html comment.processed_html
json.partial! "api/v0/shared/user", user: comment.user
end