diff --git a/plugins/chat/app/controllers/chat/api/channels_controller.rb b/plugins/chat/app/controllers/chat/api/channels_controller.rb index 47283654fee..c4d99c44cbb 100644 --- a/plugins/chat/app/controllers/chat/api/channels_controller.rb +++ b/plugins/chat/app/controllers/chat/api/channels_controller.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true CHANNEL_EDITABLE_PARAMS = %i[name description slug] -CATEGORY_CHANNEL_EDITABLE_PARAMS = %i[auto_join_users allow_channel_wide_mentions] +CATEGORY_CHANNEL_EDITABLE_PARAMS = %i[auto_join_users allow_channel_wide_mentions threading_enabled] class Chat::Api::ChannelsController < Chat::ApiController def index @@ -36,7 +36,14 @@ class Chat::Api::ChannelsController < Chat::ApiController def create channel_params = - params.require(:channel).permit(:chatable_id, :name, :slug, :description, :auto_join_users) + params.require(:channel).permit( + :chatable_id, + :name, + :slug, + :description, + :auto_join_users, + :threading_enabled, + ) # NOTE: We don't allow creating channels for anything but category chatable types # at the moment. This may change in future, at which point we will need to pass in diff --git a/plugins/chat/app/services/chat/create_category_channel.rb b/plugins/chat/app/services/chat/create_category_channel.rb index 0d25cd3c749..e13a35fb449 100644 --- a/plugins/chat/app/services/chat/create_category_channel.rb +++ b/plugins/chat/app/services/chat/create_category_channel.rb @@ -10,6 +10,7 @@ module Chat # description: "This is the best channel", # slug: "super-channel", # category_id: category.id, + # threading_enabled: true, # ) # class CreateCategoryChannel @@ -23,6 +24,7 @@ module Chat # @option params_to_create [String] slug # @option params_to_create [Boolean] auto_join_users # @option params_to_create [Integer] category_id + # @option params_to_create [Boolean] threading_enabled # @return [Service::Base::Context] policy :can_create_channel @@ -42,8 +44,12 @@ module Chat attribute :slug, :string attribute :category_id, :integer attribute :auto_join_users, :boolean, default: false + attribute :threading_enabled, :boolean, default: false - before_validation { self.auto_join_users = auto_join_users.presence || false } + before_validation do + self.auto_join_users = auto_join_users.presence || false + self.threading_enabled = threading_enabled.presence || false + end validates :category_id, presence: true validates :name, length: { maximum: SiteSetting.max_topic_title_length } @@ -70,6 +76,7 @@ module Chat description: contract.description, user_count: 1, auto_join_users: contract.auto_join_users, + threading_enabled: contract.threading_enabled, ) end diff --git a/plugins/chat/app/services/chat/update_channel.rb b/plugins/chat/app/services/chat/update_channel.rb index 08534a291d8..93a64447f2d 100644 --- a/plugins/chat/app/services/chat/update_channel.rb +++ b/plugins/chat/app/services/chat/update_channel.rb @@ -3,8 +3,8 @@ module Chat # Service responsible for updating a chat channel's name, slug, and description. # - # For a CategoryChannel, the settings for auto_join_users and allow_channel_wide_mentions - # are also editable. + # For a CategoryChannel, the settings for auto_join_users, allow_channel_wide_mentions + # and threading_enabled are also editable. # # @example # Service::Chat::UpdateChannel.call( @@ -13,6 +13,7 @@ module Chat # name: "SuperChannel", # description: "This is the best channel", # slug: "super-channel", + # threading_enaled: true, # ) # class UpdateChannel @@ -43,6 +44,7 @@ module Chat attribute :name, :string attribute :description, :string attribute :slug, :string + attribute :threading_enabled, :boolean, default: false attribute :auto_join_users, :boolean, default: false attribute :allow_channel_wide_mentions, :boolean, default: true diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-channel-settings-view.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-channel-settings-view.hbs index a27c3aec80d..78ca5ba2726 100644 --- a/plugins/chat/assets/javascripts/discourse/components/chat-channel-settings-view.hbs +++ b/plugins/chat/assets/javascripts/discourse/components/chat-channel-settings-view.hbs @@ -1,36 +1,36 @@
+
{{i18n "chat.settings.auto_join_users_info" - category=this.channel.chatable.name + category=@channel.chatable.name }}
+
{{i18n "chat.settings.channel_wide_mentions_description" - channel=this.channel.title + channel=@channel.title }}