pangbo
17 Aprile 2024, 6:18am
1
Come amministratore, non sono in grado di creare chat personali con altri utenti.
Tuttavia, secondo le impostazioni del sito, i membri dello staff dovrebbero sempre avere la possibilità di creare chat personali.
Passaggi per riprodurre:
Imposta chat allowed groups su TL0 e direct message enabled groups su moderatori.
Come amministratore, tenta di creare una chat personale con un utente TL1.
Correzione
Questo problema è correlato alla 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
Quando un utente tenta di creare una chat personale, non dovremmo verificare se l’utente di destinazione ha la possibilità di creare chat personali. Invece, come specificato nelle impostazioni del sito, dovremmo verificare se l’utente corrente ha la possibilità di creare chat personali.
Finché l’utente corrente è membro dei gruppi abilitati ai messaggi diretti o è un membro dello staff, dovrebbe essere in grado di creare una chat personale.
Ho inviato una pull request per risolvere questo problema:
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.

However, according to the site settings, staff members should always have the ability to create personal chats.

## 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 Mi Piace
Grazie @pangbo , ho appena unito la PR
Faremo una revisione più approfondita di queste impostazioni / opzioni internamente per vedere se ne abbiamo tralasciate altre.
1 Mi Piace