fix: allow staff and `direct message enabled groups` to create personal chats
This commit is contained in:
parent
8ff1efa100
commit
98f7430480
|
@ -5,7 +5,7 @@ module Chat
|
|||
attributes :can_chat, :has_chat_enabled
|
||||
|
||||
def can_chat
|
||||
SiteSetting.chat_enabled && object.guardian.can_chat? && object.guardian.can_direct_message?
|
||||
SiteSetting.chat_enabled && object.guardian.can_chat? && scope.can_create_direct_message?
|
||||
end
|
||||
|
||||
def has_chat_enabled
|
||||
|
|
|
@ -54,4 +54,19 @@ RSpec.describe Chat::ChatableUserSerializer do
|
|||
expect(serializer.as_json[:can_chat]).to eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
context "when staff creates direct messages" do
|
||||
let(:admin) { Fabricate(:admin) }
|
||||
subject(:serializer) { described_class.new(user, scope: Guardian.new(admin), root: false) }
|
||||
before { SiteSetting.direct_message_enabled_groups = Group::AUTO_GROUPS[:trust_level_4] }
|
||||
|
||||
it "can chat" do
|
||||
expect(serializer.as_json[:can_chat]).to eq(true)
|
||||
end
|
||||
|
||||
it "can't chat if user has chat disabled" do
|
||||
user.user_option.update!(chat_enabled: false)
|
||||
expect(serializer.as_json[:has_chat_enabled]).to eq(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue