FIX: allow user quotes in HTML digest emails

This commit is contained in:
Régis Hanol 2018-05-13 18:23:17 +02:00
parent 37232fcb58
commit 9d9332d8c9
2 changed files with 21 additions and 1 deletions

View File

@ -37,13 +37,15 @@ module UserNotificationsHelper
result = ""
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?
result << node.to_s
length += node.inner_text.length
return result if length >= SiteSetting.digest_min_excerpt_length
end
end
return result unless result.blank?
# If there is no first paragaph, return the first div (onebox)

View File

@ -34,5 +34,23 @@ describe UserNotificationsHelper do
SiteSetting.digest_min_excerpt_length = 50
expect(helper.email_excerpt(arg)).to eq([with_link, paragraphs[0]].join)
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