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 <jancernik12@gmail.com>
This commit is contained in:
parent
a373bf2a01
commit
6dcb099547
|
@ -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
|
||||
|
|
|
@ -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 <a href=\"https://twitter.com/EffinBirds/status/1518743508378697729\" class=\"inline-onebox-loading\" rel=\"noopener nofollow ugc\">https://twitter.com/Effi...</a>",
|
||||
)
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue