Files
danbooru/app/policies/comment_vote_policy.rb
evazion 9efb374ae5 comments: allow swapping votes.
Allow users to upvote a comment, then downvote it, without raising an
error or having to manually remove the upvote first. The upvote is
automatically removed and replaced by the downvote.

Changes to the /comment_votes API:

* `POST /comment_votes` and `DELETE /comment_votes` now return a comment
  vote instead of a comment.
* The `score` param in `POST /comment_votes` is now 1 or -1, not
  `up` or `down.`
2021-01-21 07:58:50 -06:00

14 lines
216 B
Ruby

class CommentVotePolicy < ApplicationPolicy
def create?
unbanned? && !record.comment.is_deleted?
end
def destroy?
record.user_id == user.id
end
def can_see_votes?
user.is_moderator?
end
end