mirror of
https://github.com/discourse/discourse.git
synced 2025-03-23 21:26:18 +08:00
FIX: Silenced users shouldn't be able to act on posts
This commit is contained in:
parent
2927294cc6
commit
87fa26b6c8
@ -36,6 +36,10 @@ module PostGuardian
|
|||||||
already_did_flagging = taken.any? && (taken & PostActionType.notify_flag_types.values).any?
|
already_did_flagging = taken.any? && (taken & PostActionType.notify_flag_types.values).any?
|
||||||
|
|
||||||
result = if authenticated? && post && !@user.anonymous?
|
result = if authenticated? && post && !@user.anonymous?
|
||||||
|
|
||||||
|
# Silenced users can't act on posts
|
||||||
|
return false if @user.silenced?
|
||||||
|
|
||||||
# post made by staff, but we don't allow staff flags
|
# post made by staff, but we don't allow staff flags
|
||||||
return false if is_flag &&
|
return false if is_flag &&
|
||||||
(!SiteSetting.allow_flagging_staff?) &&
|
(!SiteSetting.allow_flagging_staff?) &&
|
||||||
|
@ -104,6 +104,11 @@ describe Guardian do
|
|||||||
expect(Guardian.new(user).post_can_act?(post, :like)).to be_falsey
|
expect(Guardian.new(user).post_can_act?(post, :like)).to be_falsey
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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" do
|
it "allows flagging archived posts" do
|
||||||
post.topic.archived = true
|
post.topic.archived = true
|
||||||
expect(Guardian.new(user).post_can_act?(post, :spam)).to be_truthy
|
expect(Guardian.new(user).post_can_act?(post, :spam)).to be_truthy
|
||||||
|
Loading…
x
Reference in New Issue
Block a user