pangbo
April 17, 2024, 6:18am
1
As an admin, I am unable to create personal chats with other users.
However, according to the site settings, staff members should always have the ability to create personal chats.
Steps to reproduce:
Set chat allowed groups
to TL0 & direct message enabled groups
to moderators
As an admin, attempt to create a personal chat with a TL1 user.
Fix
This issue is related to PR #26010
# frozen_string_literal: true
module Chat
class ChatableUserSerializer < UserWithCustomFieldsSerializer
attributes :can_chat, :has_chat_enabled
def can_chat
SiteSetting.chat_enabled && object.guardian.can_chat? && object.guardian.can_direct_message?
end
def has_chat_enabled
can_chat && object.user_option&.chat_enabled
end
end
end
When a user attempts to create a personal chat, we should not verify whether the target user has the ability to create personal chats. Instead, as specified in the site settings, we should verify whether the current user has the ability to create personal chats.
As long as the current user is a member of the direct message enabled groups or is a staff member, they should be able to create a personal chat.
I have submitted a pull request to fix this issue:
discourse:main
â pangbo13:fix/staff-cannot-create-personal-chats
opened 05:57AM - 17 Apr 24 UTC
As an admin, I am unable to create personal chats with other users.
![image](⊠https://github.com/discourse/discourse/assets/51732678/da04af6c-0134-45c4-b1a6-ecd6cbd16fa9)
However, according to the site settings, staff members should always have the ability to create personal chats.
![image](https://github.com/discourse/discourse/assets/51732678/88bd0a5f-ad33-47ac-9086-58b2f74924be)
## Steps to reproduce:
1. Set `chat allowed groups` to TL0 & `direct message enabled groups` to moderators
2. As an admin, attempt to create a personal chat with a TL1 user.
## Fix
This issue is related to PR https://github.com/discourse/discourse/pull/26010
https://github.com/discourse/discourse/blob/df373d90fe9460b49aaa771e138aebf3f768c803/plugins/chat/app/serializers/chat/chatable_user_serializer.rb#L8
When a user attempts to create a personal chat, we should not verify whether the target user has the ability to create personal chats. Instead, as specified in the site settings, we should verify whether the **current user** has the ability to create personal chats.
As long as the current user is a member of the direct message enabled groups or is a staff member, they should be able to create a personal chat.
4 Likes
zogstrip
(RĂ©gis Hanol)
June 25, 2024, 10:18am
4
Thanks @pangbo , I just merged the PR
Weâll do a more thorough review of those settings / options internally to see if we missed any other.
1 Like