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:
@@ -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
|
||||
|
||||
@@ -4,4 +4,8 @@ class PostApprovalPolicy < ApplicationPolicy
|
||||
def create?
|
||||
user.is_approver?
|
||||
end
|
||||
|
||||
def can_bypass_approval_limits?
|
||||
user.is_admin?
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user