diff --git a/app/helpers/user_notifications_helper.rb b/app/helpers/user_notifications_helper.rb index dd57d457943..b284f69c611 100644 --- a/app/helpers/user_notifications_helper.rb +++ b/app/helpers/user_notifications_helper.rb @@ -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) diff --git a/spec/helpers/user_notifications_helper_spec.rb b/spec/helpers/user_notifications_helper_spec.rb index dcd5cdcfce0..32e1f140809 100644 --- a/spec/helpers/user_notifications_helper_spec.rb +++ b/spec/helpers/user_notifications_helper_spec.rb @@ -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 +
BEFORE
+++ +This is a user quote
+
AFTER
+ HTML + + expect(helper.email_excerpt(cooked)).to eq "BEFORE
\nThis is a user quote
\n
AFTER
" + end end end