posts: allow admins to approve the same post twice.

This is so admins can overrule flags and always have the final say in whether a
post is approved, even in the event of coordinated or sockpuppet flagging.

Fixes #4980: Way to mark flags as invalid for admins
This commit is contained in:
evazion
2022-06-05 15:23:24 -05:00
parent 907194fc6f
commit acc4a21687
3 changed files with 27 additions and 1 deletions

View File

@@ -18,7 +18,7 @@ class PostApproval < ApplicationRecord
errors.add(:base, "You cannot approve a post you uploaded")
end
if post.approver == user || post.approvals.exists?(user: user)
if (post.approver == user || post.approvals.exists?(user: user)) && !policy(user).can_bypass_approval_limits?
errors.add(:base, "You have previously approved this post and cannot approve it again")
end
end

View File

@@ -4,4 +4,8 @@ class PostApprovalPolicy < ApplicationPolicy
def create?
user.is_approver?
end
def can_bypass_approval_limits?
user.is_admin?
end
end