A platform for community discussion. Free, open, simple.
FIX: Silenced users shouldn't be able to act on posts
Robin Ward87fa26b6c80f
diff --git a/lib/guardian/post_guardian.rb b/lib/guardian/post_guardian.rbindex af56156c023..a4c2741f1b0 100644--- a/lib/guardian/post_guardian.rb+++ b/lib/guardian/post_guardian.rb@@ -36,6 +36,10 @@ module PostGuardianalready_did_flagging = taken.any? && (taken & PostActionType.notify_flag_types.values).any?result = if authenticated? && post && [email protected]?++ # Silenced users can't act on posts+ return false if @user.silenced?+# post made by staff, but we don't allow staff flagsreturn false if is_flag &&(!SiteSetting.allow_flagging_staff?) &&diff --git a/spec/components/guardian_spec.rb b/spec/components/guardian_spec.rbindex bdd0ef60926..ffc09ff97a2 100644--- a/spec/components/guardian_spec.rb+++ b/spec/components/guardian_spec.rb@@ -104,6 +104,11 @@ describe Guardian doexpect(Guardian.new(user).post_can_act?(post, :like)).to be_falseyend+ it "returns false when the user is silenced" do+ UserSilencer.silence(user, admin)+ expect(Guardian.new(user).post_can_act?(post, :spam)).to be_falsey+ end+it "allows flagging archived posts" dopost.topic.archived = trueexpect(Guardian.new(user).post_can_act?(post, :spam)).to be_truthy