diff --git a/plugins/chat/app/services/chat/publisher.rb b/plugins/chat/app/services/chat/publisher.rb index 5aa87e9ad05..81e3fd4c736 100644 --- a/plugins/chat/app/services/chat/publisher.rb +++ b/plugins/chat/app/services/chat/publisher.rb @@ -88,9 +88,9 @@ module Chat end def self.publish_processed!(chat_message) + chat_channel = chat_message.chat_channel message_bus_targets = calculate_publish_targets(chat_channel, chat_message) - chat_channel = chat_message.chat_channel content = { type: :processed, chat_message: { diff --git a/plugins/chat/assets/javascripts/discourse/services/chat-pane-base-subscriptions-manager.js b/plugins/chat/assets/javascripts/discourse/services/chat-pane-base-subscriptions-manager.js index 6e102f9db5b..3a09348d6a0 100644 --- a/plugins/chat/assets/javascripts/discourse/services/chat-pane-base-subscriptions-manager.js +++ b/plugins/chat/assets/javascripts/discourse/services/chat-pane-base-subscriptions-manager.js @@ -142,6 +142,7 @@ export default class ChatPaneBaseSubscriptionsManager extends Service { const message = this.messagesManager.findMessage(data.chat_message.id); if (message) { message.cooked = data.chat_message.cooked; + message.incrementVersion(); this.afterProcessedMessage(message); } } diff --git a/plugins/chat/spec/system/chat_message_onebox_spec.rb b/plugins/chat/spec/system/chat_message_onebox_spec.rb new file mode 100644 index 00000000000..d697ac9959a --- /dev/null +++ b/plugins/chat/spec/system/chat_message_onebox_spec.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +RSpec.describe "Chat message onebox", type: :system, js: true do + let(:chat_page) { PageObjects::Pages::Chat.new } + let(:channel_page) { PageObjects::Pages::ChatChannel.new } + + fab!(:current_user) { Fabricate(:user) } + fab!(:channel_1) { Fabricate(:category_channel) } + + before do + chat_system_bootstrap + channel_1.add(current_user) + sign_in(current_user) + end + + context "when sending a message with a link" do + before do + SiteSetting.enable_inline_onebox_on_all_domains = true + + full_onebox_html = <<~HTML.chomp + + HTML + Oneboxer + .stubs(:cached_onebox) + .with("https://en.wikipedia.org/wiki/Hyperlink") + .returns(full_onebox_html) + + stub_request(:get, "https://en.wikipedia.org/wiki/Hyperlink").to_return( + status: 200, + body: "a", + ) + end + + it "is oneboxed" do + chat_page.visit_channel(channel_1) + channel_page.send_message("https://en.wikipedia.org/wiki/Hyperlink") + + expect(page).to have_content("This is a test") + end + end +end