Skip to content

A platform for community discussion. Free, open, simple.

FIX: Chat thread race condition issues (#22533)

Martin Brennan0f9e4da4ef9a
diff --git a/plugins/chat/assets/javascripts/discourse/services/chat-channel-pane-subscriptions-manager.js b/plugins/chat/assets/javascripts/discourse/services/chat-channel-pane-subscriptions-manager.js
index b381b2c1a47..b95a10b0fb1 100644
--- a/plugins/chat/assets/javascripts/discourse/services/chat-channel-pane-subscriptions-manager.js
+++ b/plugins/chat/assets/javascripts/discourse/services/chat-channel-pane-subscriptions-manager.js
@@ -36,7 +36,7 @@ export default class ChatChannelPaneSubscriptionsManager extends ChatPaneBaseSub
handleThreadOriginalMessageUpdate(data) {
const message = this.messagesManager.findMessage(data.original_message_id);
- if (message) {
+ if (message.thread) {
message.thread.preview = ChatThreadPreview.create(data.preview);
}
}
diff --git a/plugins/chat/lib/chat/message_creator.rb b/plugins/chat/lib/chat/message_creator.rb
index ecf0e022d64..9cbd6775c32 100644
--- a/plugins/chat/lib/chat/message_creator.rb
+++ b/plugins/chat/lib/chat/message_creator.rb
@@ -191,15 +191,6 @@ module Chat
@chat_message.in_reply_to.thread_id = thread.id
end
- if @chat_message.chat_channel.threading_enabled
- Chat::Publisher.publish_thread_created!(
- @chat_message.chat_channel,
- @chat_message.in_reply_to,
- thread.id,
- @staged_thread_id,
- )
- end
-
@chat_message.thread_id = thread.id
# NOTE: We intentionally do not try to correct thread IDs within the chain
@@ -223,6 +214,15 @@ module Chat
FROM thread_updater
WHERE thread_id IS NULL AND chat_messages.id = thread_updater.id
SQL
+
+ if @chat_message.chat_channel.threading_enabled
+ Chat::Publisher.publish_thread_created!(
+ @chat_message.chat_channel,
+ @chat_message.in_reply_to,
+ thread.id,
+ @staged_thread_id,
+ )
+ end
end
def resolved_thread