A platform for community discussion. Free, open, simple.
FIX: Remove chat default channel setting (#28170)
Gabriel Grubba633a19fcc09a
diff --git a/db/migrate/20240731143458_remove_chat_default_channel_id.rb b/db/migrate/20240731143458_remove_chat_default_channel_id.rbnew file mode 100644index 00000000000..d09875c772b--- /dev/null+++ b/db/migrate/20240731143458_remove_chat_default_channel_id.rb@@ -0,0 +1,10 @@+# frozen_string_literal: true+class RemoveChatDefaultChannelId < ActiveRecord::Migration[7.1]+ def up+ execute "DELETE FROM site_settings WHERE name = 'chat_default_channel_id'"+ end++ def down+ raise ActiveRecord::IrreversibleMigration+ end+enddiff --git a/plugins/chat/app/validators/chat/default_channel_validator.rb b/plugins/chat/app/validators/chat/default_channel_validator.rbdeleted file mode 100644index c8f23893851..00000000000--- a/plugins/chat/app/validators/chat/default_channel_validator.rb+++ /dev/null@@ -1,17 +0,0 @@-# frozen_string_literal: true--module Chat- class DefaultChannelValidator- def initialize(opts = {})- @opts = opts- end-- def valid_value?(value)- !!(value == "" || Chat::Channel.find_by(id: value.to_i)&.public_channel?)- end-- def error_message- I18n.t("site_settings.errors.chat_default_channel")- end- end-enddiff --git a/plugins/chat/assets/javascripts/discourse/routes/chat-channels.js b/plugins/chat/assets/javascripts/discourse/routes/chat-channels.jsindex 555c50ce7aa..a1c9cd5710c 100644--- a/plugins/chat/assets/javascripts/discourse/routes/chat-channels.js+++ b/plugins/chat/assets/javascripts/discourse/routes/chat-channels.js@@ -12,30 +12,13 @@ export default class ChatChannelsRoute extends DiscourseRoute {beforeModel() {const id = this.currentUser.custom_fields.last_chat_channel_id;- const defaultChannelId = this.siteSettings.chat_default_channel_id;if (this.site.desktopView) {if (id) {this.chatChannelsManager.find(id).then((c) => {return this.router.replaceWith("chat.channel", ...c.routeModels);});} else {- // first time browsing chat in desktop and the preferred index is channels- if (defaultChannelId) {- this.chatChannelsManager.find(defaultChannelId).then((c) => {- return this.router.replaceWith("chat.channel", ...c.routeModels);- });- } else {- this.router.replaceWith("chat.browse.open");- }- }- } else {- if (- defaultChannelId &&- this.router.currentRoute?.parent?.params?.channelId !== defaultChannelId- ) {- this.chatChannelsManager.find(defaultChannelId).then((c) => {- return this.router.replaceWith("chat.channel", ...c.routeModels);- });+ this.router.replaceWith("chat.browse.open");}}}diff --git a/plugins/chat/assets/javascripts/discourse/services/chat-drawer-router.js b/plugins/chat/assets/javascripts/discourse/services/chat-drawer-router.jsindex c1fa0dacb48..cbd0b5e460c 100644--- a/plugins/chat/assets/javascripts/discourse/services/chat-drawer-router.js+++ b/plugins/chat/assets/javascripts/discourse/services/chat-drawer-router.js@@ -179,14 +179,6 @@ export default class ChatDrawerRouter extends Service {return this.stateFor(this.#routeFromURL("/chat/direct-messages"));}- if (this.siteSettings.chat_default_channel_id) {- return this.chatChannelsManager- .find(this.siteSettings.chat_default_channel_id)- .then((c) => {- return this.router.replaceWith("chat.channel", ...c.routeModels);- });- }-if (!this.siteSettings.enable_public_channels) {return this.stateFor(this.#routeFromURL("/chat/direct-messages"));}diff --git a/plugins/chat/config/locales/server.en.yml b/plugins/chat/config/locales/server.en.ymlindex 7b049c2cca0..0886645f4cf 100644--- a/plugins/chat/config/locales/server.en.yml+++ b/plugins/chat/config/locales/server.en.yml@@ -11,7 +11,6 @@ en:chat_allowed_messages_for_other_trust_levels: "Number of messages that users with trust levels 1-4 is allowed to send in 30 seconds. Set to '0' to disable limit."chat_silence_user_sensitivity: "The likelihood that a user flagged in chat will be automatically silenced."chat_auto_silence_from_flags_duration: "Number of minutes that users will be silenced for when they are automatically silenced due to flagged chat messages."- chat_default_channel_id: "The chat channel that will be opened by default when a user has no unread messages or mentions in other channels."chat_duplicate_message_sensitivity: "The likelihood that a duplicate message by the same sender will be blocked in a short period. Decimal number between 0 and 1.0, with 1.0 being the highest setting (blocks messages more frequently in a shorter amount of time). Set to `0` to allow duplicate messages."chat_minimum_message_length: "Minimum number of characters for a chat message."chat_allow_uploads: "Allow uploads in public chat channels and direct message channels."diff --git a/plugins/chat/config/settings.yml b/plugins/chat/config/settings.ymlindex 1cd4a81f639..bd0ccff7ab3 100644--- a/plugins/chat/config/settings.yml+++ b/plugins/chat/config/settings.yml@@ -63,10 +63,6 @@ chat:- archived- open- closed- chat_default_channel_id:- default: ""- client: true- validator: "Chat::DefaultChannelValidator"chat_duplicate_message_sensitivity:type: floatdefault: 0.5diff --git a/plugins/chat/spec/validators/chat_default_channel_validator_spec.rb b/plugins/chat/spec/validators/chat_default_channel_validator_spec.rbdeleted file mode 100644index 990666b7fdb..00000000000--- a/plugins/chat/spec/validators/chat_default_channel_validator_spec.rb+++ /dev/null@@ -1,26 +0,0 @@-# frozen_string_literal: true--describe Chat::DefaultChannelValidator do- fab!(:channel) { Fabricate(:category_channel) }-- it "provides an error message" do- validator = described_class.new- expect(validator.error_message).to eq(I18n.t("site_settings.errors.chat_default_channel"))- end-- it "returns true if public channel id" do- validator = described_class.new- expect(validator.valid_value?(channel.id)).to eq(true)- end-- it "returns true if empty string" do- validator = described_class.new- expect(validator.valid_value?("")).to eq(true)- end-- it "returns false if not a public channel" do- validator = described_class.new- channel.destroy!- expect(validator.valid_value?(channel.id)).to eq(false)- end-end