FIX: chat replies are not always in a thread (#27023)

When you reply to a chat message, we [always create a thread][1]. But when the channel we're in doesn't have threading enabled, the reply is _technically_ not a thread.

This changes the `in_thread?` method to check for both the presence of a `thread_id` and to ensure that the channel has `threading_enabled`.

Internal ref - t/128103/3

[1]: e6e3eaf472/plugins/chat/app/services/chat/create_message.rb (L110-L115)
This commit is contained in:
Régis Hanol 2024-05-16 16:10:23 +02:00 committed by GitHub
parent af6759f5e2
commit 02469d5795
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 3 deletions

View File

@ -266,7 +266,7 @@ module Chat
end
def in_thread?
self.thread_id.present?
self.thread_id.present? && self.chat_channel.threading_enabled
end
def thread_reply?

View File

@ -205,7 +205,9 @@ RSpec.describe Chat::Api::ChannelMessagesController do
let(:message) { "This is a message" }
describe "for category" do
fab!(:chat_channel) { Fabricate(:category_channel, chatable: category) }
fab!(:chat_channel) do
Fabricate(:category_channel, chatable: category, threading_enabled: true)
end
before do
chat_channel.add(user)

View File

@ -70,7 +70,7 @@ RSpec.describe "User menu notifications | sidebar", type: :system do
end
context "when category channel" do
fab!(:channel_1) { Fabricate(:chat_channel) }
fab!(:channel_1) { Fabricate(:chat_channel, threading_enabled: true) }
before do
Jobs.run_immediately!