A platform for community discussion. Free, open, simple.
FIX: Publish new DM channel after transaction commits (#40148)
Martin Brennan34ad77e8b1cc
diff --git a/plugins/chat/app/services/chat/create_message.rb b/plugins/chat/app/services/chat/create_message.rbindex c409c8db47d..0867256557b 100644--- a/plugins/chat/app/services/chat/create_message.rb+++ b/plugins/chat/app/services/chat/create_message.rb@@ -83,9 +83,9 @@ module Chatstep :create_webhook_eventstep :update_channel_last_messagestep :update_membership_last_read- step :process_direct_message_channelend+ step :process_direct_message_channelstep :publish_new_threadstep :processstep :publish_user_tracking_statediff --git a/plugins/chat/spec/services/chat/create_message_spec.rb b/plugins/chat/spec/services/chat/create_message_spec.rbindex a819a8a6484..75f6beb1107 100644--- a/plugins/chat/spec/services/chat/create_message_spec.rb+++ b/plugins/chat/spec/services/chat/create_message_spec.rb@@ -182,6 +182,16 @@ RSpec.describe Chat::CreateMessage do)resultend++ it "processes the direct message channel outside of the service transaction" do+ initial_depth = ActiveRecord::Base.connection.open_transactions+ transaction_depth_when_called = nil+ Chat::Action::PublishAndFollowDirectMessageChannel+ .expects(:call)+ .with { transaction_depth_when_called = ActiveRecord::Base.connection.open_transactions }+ result+ expect(transaction_depth_when_called).to eq(initial_depth)+ endendshared_examples "a message in a thread" do