FIX: allow staff members to send PMs when enable_private_messages is disabled
This commit is contained in:
parent
c191e2e84c
commit
b32f33b3f0
|
@ -279,9 +279,7 @@ class Guardian
|
|||
# Have to be a basic level at least
|
||||
@user.has_trust_level?(SiteSetting.min_trust_to_send_messages) &&
|
||||
# PMs are enabled
|
||||
(SiteSetting.enable_private_messages ||
|
||||
@user.username == SiteSetting.site_contact_username ||
|
||||
@user == Discourse.system_user) &&
|
||||
(is_staff? || SiteSetting.enable_private_messages) &&
|
||||
# Can't send PMs to suspended users
|
||||
(is_staff? || target.is_a?(Group) || !target.suspended?) &&
|
||||
# Blocked users can only send PM to staff
|
||||
|
|
|
@ -168,14 +168,13 @@ describe Guardian do
|
|||
context "enable_private_messages is false" do
|
||||
before { SiteSetting.enable_private_messages = false }
|
||||
|
||||
it "returns false if user is not the contact user" do
|
||||
expect(Guardian.new(user).can_send_private_message?(another_user)).to be_falsey
|
||||
it "returns false if user is not staff member" do
|
||||
expect(Guardian.new(trust_level_4).can_send_private_message?(another_user)).to be_falsey
|
||||
end
|
||||
|
||||
it "returns true for the contact user and system user" do
|
||||
SiteSetting.site_contact_username = user.username
|
||||
expect(Guardian.new(user).can_send_private_message?(another_user)).to be_truthy
|
||||
expect(Guardian.new(Discourse.system_user).can_send_private_message?(another_user)).to be_truthy
|
||||
it "returns true for staff member" do
|
||||
expect(Guardian.new(moderator).can_send_private_message?(another_user)).to be_truthy
|
||||
expect(Guardian.new(admin).can_send_private_message?(another_user)).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue