pangbo
17.Апрель.2024 06:18:49
1
Как администратор, я не могу создавать личные чаты с другими пользователями.
Однако, согласно настройкам сайта, сотрудники всегда должны иметь возможность создавать личные чаты.
Шаги для воспроизведения:
Установите chat allowed groups в TL0 и direct message enabled groups в модераторы.
Как администратор, попробуйте создать личный чат с пользователем уровня TL1.
Исправление
Эта проблема связана с 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
Когда пользователь пытается создать личный чат, мы не должны проверять, имеет ли целевой пользователь возможность создавать личные чаты. Вместо этого, в соответствии с настройками сайта, мы должны проверять, имеет ли текущий пользователь возможность создавать личные чаты.
Пока текущий пользователь является членом групп, разрешающих прямые сообщения, или является сотрудником, он должен иметь возможность создавать личный чат.
Я отправил запрос на слияние для исправления этой проблемы:
main ← pangbo13:fix/staff-cannot-create-personal-chats
merged 10:17AM - 25 Jun 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 лайка
Спасибо @pangbo , я только что слил PR
Мы проведем более тщательный обзор этих настроек / опций внутренне, чтобы проверить, не упустили ли мы что-то еще.
1 лайк