Skip to content

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.rb
index ce3864ecc8a..c58ffff15c3 100644
--- a/lib/guardian/post_guardian.rb
+++ b/lib/guardian/post_guardian.rb
@@ -37,8 +37,8 @@ module PostGuardian
result = 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 flags
return false if is_flag &&
diff --git a/spec/components/guardian_spec.rb b/spec/components/guardian_spec.rb
index bddb5890316..03c4d2c14d6 100644
--- a/spec/components/guardian_spec.rb
+++ b/spec/components/guardian_spec.rb
@@ -104,9 +104,11 @@ describe Guardian do
expect(Guardian.new(user).post_can_act?(post, :like)).to be_falsey
end
- it "returns false when the user is silenced" do
+ it "works as expected for silenced users" do
UserSilencer.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_truthy
end
it "allows flagging archived posts" do