A platform for community discussion. Free, open, simple.
FIX: Allow silenced users to like / bookmark, just not flag.
Robin Warda83f66249299
diff --git a/lib/guardian/post_guardian.rb b/lib/guardian/post_guardian.rbindex ce3864ecc8a..c58ffff15c3 100644--- a/lib/guardian/post_guardian.rb+++ b/lib/guardian/post_guardian.rb@@ -37,8 +37,8 @@ module PostGuardianresult = if authenticated? && post && [email protected]?- # Silenced users can't act on posts- return false if @user.silenced?+ # Silenced users can't flag+ return false if is_flag && @user.silenced?# post made by staff, but we don't allow staff flagsreturn false if is_flag &&diff --git a/spec/components/guardian_spec.rb b/spec/components/guardian_spec.rbindex bddb5890316..03c4d2c14d6 100644--- a/spec/components/guardian_spec.rb+++ b/spec/components/guardian_spec.rb@@ -104,9 +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+ it "works as expected for silenced users" doUserSilencer.silence(user, admin)expect(Guardian.new(user).post_can_act?(post, :spam)).to be_falsey+ expect(Guardian.new(user).post_can_act?(post, :like)).to be_truthy+ expect(Guardian.new(user).post_can_act?(post, :bookmark)).to be_truthyendit "allows flagging archived posts" do