FIX: Chat publisher publishing to thread when threading disabled (#21179)

Followup to bd5c5c4b5f, a
bug was introduced there for any channel that did not have
threading enabled or sites with the experimental threading
disabled. When the user replied to another chat message,
since this is always a thread in the background, we weren't
sending any MessageBus messages to the main channel, since
the message was a thread reply.

However in the UI these messages still show in the main stream
of the channel if threading is turned off, so the UI was not
reacting to these things happening in the backend. The worst
issue was that new clients would not see new replies sent in
reply to other messages in the channel.
This commit is contained in:
Martin Brennan
2023-04-20 14:38:00 +10:00
committed by GitHub
parent 525d23e0e0
commit 351e3ccd98
2 changed files with 192 additions and 30 deletions
+17 -13
View File
@@ -15,18 +15,22 @@ module Chat
end
def self.calculate_publish_targets(channel, message)
targets =
if message.thread_om?
[
root_message_bus_channel(channel.id),
thread_message_bus_channel(channel.id, message.thread_id),
]
elsif message.thread_reply?
[thread_message_bus_channel(channel.id, message.thread_id)]
else
[root_message_bus_channel(channel.id)]
end
targets
return [root_message_bus_channel(channel.id)] if !allow_publish_to_thread?(channel)
if message.thread_om?
[
root_message_bus_channel(channel.id),
thread_message_bus_channel(channel.id, message.thread_id),
]
elsif message.thread_reply?
[thread_message_bus_channel(channel.id, message.thread_id)]
else
[root_message_bus_channel(channel.id)]
end
end
def self.allow_publish_to_thread?(channel)
SiteSetting.enable_experimental_chat_threaded_discussions && channel.threading_enabled
end
def self.publish_new!(chat_channel, chat_message, staged_id)
@@ -40,7 +44,7 @@ module Chat
# NOTE: This means that the read count is only updated in the client
# for new messages in the main channel stream, maybe in future we want to
# do this for thread messages as well?
if !chat_message.thread_reply?
if !chat_message.thread_reply? || !allow_publish_to_thread?(chat_channel)
MessageBus.publish(
self.new_messages_message_bus_channel(chat_channel.id),
{