comments: remove rule that you can't upvote your own comments.

Remove this rule for several reasons:

* A single upvote usually isn't enough to matter, especially with the
  new comment threshold.
* It felt weird that trying to vote on a comment could fail.
* Disabling the upvote button on your own comments feels weird.
* Most other sites allow you to upvote your own comments.
* You're allowed to upvote your own uploads, so it doesn't make sense
  that you can't upvote your own comments.
This commit is contained in:
evazion
2021-01-21 02:27:30 -06:00
parent 9efb374ae5
commit 9f313c94d1
2 changed files with 2 additions and 7 deletions

View File

@@ -33,6 +33,8 @@
* The maximum comment threshold is now 5 and the minumum threshold is now
-100. You can't set your threshold any higher or lower than this.
* Removed the rule that you can't upvote your own comments.
* Changed the way [quote] tags look. Now quotes are Reddit-style instead of
traditional forum style.

View File

@@ -4,7 +4,6 @@ class CommentVote < ApplicationRecord
validates_presence_of :score
validates_uniqueness_of :user_id, :scope => :comment_id, :message => "have already voted for this comment"
validate :validate_comment_can_be_down_voted
validates_inclusion_of :score, :in => [-1, 1], :message => "must be 1 or -1"
after_create :update_score_after_create
@@ -25,12 +24,6 @@ class CommentVote < ApplicationRecord
q.apply_default_order(params)
end
def validate_comment_can_be_down_voted
if is_positive? && comment.creator == CurrentUser.user
errors.add(:base, "You cannot upvote your own comments")
end
end
def is_positive?
score == 1
end