mirror of
https://github.com/discourse/discourse.git
synced 2025-01-17 02:42:44 +08:00
f4e51e0789
Allows users to create DMs by selecting groups as a target. It also allows adding user groups to an existing chat - When creating the channel, it expands the user group and adds all its members with chat enabled to the channel. - After creation, there's no difference between adding a group or adding its members individually. - Users can add multiple groups and users simultaneously. - There are UI validations; the member count preview updates according to the member count of added groups, and it does not allow users to add more members than SiteSetting.chat_max_direct_message_users."
21 lines
493 B
Ruby
21 lines
493 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Chat
|
|
class ChatableGroupSerializer < BasicGroupSerializer
|
|
attributes :chat_enabled, :chat_enabled_user_count, :can_chat
|
|
|
|
def chat_enabled
|
|
SiteSetting.chat_enabled
|
|
end
|
|
|
|
def chat_enabled_user_count
|
|
object.users.count { |user| user.user_option&.chat_enabled }
|
|
end
|
|
|
|
def can_chat
|
|
# + 1 for current user
|
|
chat_enabled && chat_enabled_user_count + 1 <= SiteSetting.chat_max_direct_message_users
|
|
end
|
|
end
|
|
end
|