From 6dcb099547a2684f31258eed0d29a5db21d53ec5 Mon Sep 17 00:00:00 2001 From: Blake Erickson Date: Thu, 16 Mar 2023 13:48:21 -0600 Subject: [PATCH] FIX: Escaped mentions in chat excerpts Mentions are now displayed as using the non-cooked message which fixes the problem. This is not ideal. I think we might want to rework how these excerpts are created and rendered in the near future. Co-authored-by: Jan Cernik --- plugins/chat/app/models/chat_message.rb | 2 +- plugins/chat/spec/models/chat_message_spec.rb | 18 ------------------ 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/plugins/chat/app/models/chat_message.rb b/plugins/chat/app/models/chat_message.rb index 13039d6421d..be14d09e496 100644 --- a/plugins/chat/app/models/chat_message.rb +++ b/plugins/chat/app/models/chat_message.rb @@ -90,7 +90,7 @@ class ChatMessage < ActiveRecord::Base return uploads.first.original_filename if cooked.blank? && uploads.present? # this may return blank for some complex things like quotes, that is acceptable - PrettyText.excerpt(cooked, max_length, { text_entities: true }) + PrettyText.excerpt(message, max_length, { text_entities: true }) end def cooked_for_excerpt diff --git a/plugins/chat/spec/models/chat_message_spec.rb b/plugins/chat/spec/models/chat_message_spec.rb index de1f70540a9..f12d2308e54 100644 --- a/plugins/chat/spec/models/chat_message_spec.rb +++ b/plugins/chat/spec/models/chat_message_spec.rb @@ -287,24 +287,6 @@ describe ChatMessage do COOKED ) expect(message.excerpt).to eq("https://twitter.com/EffinBirds/status/1518743508378697729") - message = - Fabricate.build( - :chat_message, - message: - "wow check out these birbs https://twitter.com/EffinBirds/status/1518743508378697729", - ) - expect(message.excerpt).to eq( - "wow check out these birbs https://twitter.com/Effi...", - ) - end - - it "returns an empty string if PrettyText.excerpt returns empty string" do - message = Fabricate(:chat_message, message: <<~MSG) - [quote="martin, post:30, topic:3179, full:true"] - This is a real **quote** topic with some *markdown* in it I can quote. - [/quote] - MSG - expect(message.excerpt).to eq("") end it "excerpts upload file name if message is empty" do