# Невозможно создать личные чаты в роли администратора

**URL:** https://meta.discourse.org/t/cant-create-personal-chats-as-an-admin/304220
**Category:** Bug
**Tags:** chat, fixed
**Created:** [17.Апрель.2024 06:18:49 UTC](https://meta.discourse.org/t/cant-create-personal-chats-as-an-admin/304220 "2024-04-17T06:18:49Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![pangbo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pangbo/32/538562_2.png) [@pangbo](https://meta.discourse.org/u/pangbo)
#### Post date: [17.Апрель.2024 06:18:49 UTC](https://meta.discourse.org/t/cant-create-personal-chats-as-an-admin/304220/1 "2024-04-17T06:18:49Z")

</div>

Как администратор, я не могу создавать личные чаты с другими пользователями.

 ![image](https://global.discourse-cdn.com/meta/original/4X/9/a/c/9acadd4d8ceebb60c1658f6e065df40f4696c49c.png)

Однако, согласно настройкам сайта, сотрудники всегда должны иметь возможность создавать личные чаты.

 ![image](https://global.discourse-cdn.com/meta/original/4X/f/2/3/f236aeb6c0d582952d7ab2fe121ac03547ba8080.png)

## Шаги для воспроизведения:

1. Установите `chat allowed groups` в TL0 и `direct message enabled groups` в модераторы.
2. Как администратор, попробуйте создать личный чат с пользователем уровня TL1.

## Исправление

Эта проблема связана с PR [#26010](https://github.com/discourse/discourse/pull/26010)

> <https://github.com/discourse/discourse/blob/df373d90fe9460b49aaa771e138aebf3f768c803/plugins/chat/app/serializers/chat/chatable_user_serializer.rb#L8>

Когда пользователь пытается создать личный чат, мы не должны проверять, имеет ли целевой пользователь возможность создавать личные чаты. Вместо этого, в соответствии с настройками сайта, мы должны проверять, имеет ли **текущий пользователь** возможность создавать личные чаты.

Пока текущий пользователь является членом групп, разрешающих прямые сообщения, или является сотрудником, он должен иметь возможность создавать личный чат.

Я отправил запрос на слияние для исправления этой проблемы:

> <https://github.com/discourse/discourse/pull/26655>
>
> 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.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [25.Июнь.2024 10:18:40 UTC](https://meta.discourse.org/t/cant-create-personal-chats-as-an-admin/304220/4 "2024-06-25T10:18:40Z")

</div>

Спасибо @pangbo, я только что слил PR 👍

Мы проведем более тщательный обзор этих настроек / опций внутренне, чтобы проверить, не упустили ли мы что-то еще.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [25.Июнь.2024 10:18:44 UTC](https://meta.discourse.org/t/cant-create-personal-chats-as-an-admin/304220/5 "2024-06-25T10:18:44Z")

</div>


