mirror of
https://github.com/discourse/discourse.git
synced 2025-03-22 23:26:41 +08:00
FIX: allow user quotes in HTML digest emails
This commit is contained in:
parent
37232fcb58
commit
9d9332d8c9
@ -37,13 +37,15 @@ module UserNotificationsHelper
|
|||||||
|
|
||||||
result = ""
|
result = ""
|
||||||
length = 0
|
length = 0
|
||||||
doc.css('body > p, aside.onebox, body > ul').each do |node|
|
|
||||||
|
doc.css('body > p, aside.onebox, body > ul, body > blockquote').each do |node|
|
||||||
if node.text.present?
|
if node.text.present?
|
||||||
result << node.to_s
|
result << node.to_s
|
||||||
length += node.inner_text.length
|
length += node.inner_text.length
|
||||||
return result if length >= SiteSetting.digest_min_excerpt_length
|
return result if length >= SiteSetting.digest_min_excerpt_length
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return result unless result.blank?
|
return result unless result.blank?
|
||||||
|
|
||||||
# If there is no first paragaph, return the first div (onebox)
|
# If there is no first paragaph, return the first div (onebox)
|
||||||
|
@ -34,5 +34,23 @@ describe UserNotificationsHelper do
|
|||||||
SiteSetting.digest_min_excerpt_length = 50
|
SiteSetting.digest_min_excerpt_length = 50
|
||||||
expect(helper.email_excerpt(arg)).to eq([with_link, paragraphs[0]].join)
|
expect(helper.email_excerpt(arg)).to eq([with_link, paragraphs[0]].join)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "uses user quotes but not post quotes" do
|
||||||
|
cooked = <<~HTML
|
||||||
|
<p>BEFORE</p>
|
||||||
|
<blockquote>
|
||||||
|
<p>This is a user quote</p>
|
||||||
|
</blockquote>
|
||||||
|
<aside class="quote" data-post="3" data-topic="87369">
|
||||||
|
<div class="title">A Title</div>
|
||||||
|
<blockquote>
|
||||||
|
<p>This is a post quote</p>
|
||||||
|
</blockquote>
|
||||||
|
</aside>
|
||||||
|
<p>AFTER</p>
|
||||||
|
HTML
|
||||||
|
|
||||||
|
expect(helper.email_excerpt(cooked)).to eq "<p>BEFORE</p><blockquote>\n <p>This is a user quote</p>\n</blockquote><p>AFTER</p>"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user