Skip to content

A platform for community discussion. Free, open, simple.

Make `email_excerpt` method take an optional `post` param (#7570)

Osama Sayegh14bae6d52d07
diff --git a/app/helpers/user_notifications_helper.rb b/app/helpers/user_notifications_helper.rb
index a5cea9c8b1a..d7e619f0298 100644
--- a/app/helpers/user_notifications_helper.rb
+++ b/app/helpers/user_notifications_helper.rb
@@ -51,9 +51,9 @@ module UserNotificationsHelper
doc.css('div').first
end
- def email_excerpt(html_arg)
+ def email_excerpt(html_arg, post = nil)
html = (first_paragraphs_from(html_arg) || html_arg).to_s
- PrettyText.format_for_email(html).html_safe
+ PrettyText.format_for_email(html, post).html_safe
end
def normalize_name(name)
diff --git a/app/mailers/user_notifications.rb b/app/mailers/user_notifications.rb
index d1bf28124fe..cf73aa5abe8 100644
--- a/app/mailers/user_notifications.rb
+++ b/app/mailers/user_notifications.rb
@@ -205,7 +205,7 @@ class UserNotifications < ActionMailer::Base
@excerpts = {}
@popular_topics.map do |t|
- @excerpts[t.first_post.id] = email_excerpt(t.first_post.cooked) if t.first_post.present?
+ @excerpts[t.first_post.id] = email_excerpt(t.first_post.cooked, t.first_post) if t.first_post.present?
end
# Try to find 3 interesting stats for the top of the digest
diff --git a/app/views/user_notifications/digest.html.erb b/app/views/user_notifications/digest.html.erb
index e0cf541a466..ec36e142ba2 100644
--- a/app/views/user_notifications/digest.html.erb
+++ b/app/views/user_notifications/digest.html.erb
@@ -248,7 +248,7 @@ body, table, td, th, h1, h2, h3 {font-family: Helvetica, Arial, sans-serif !impo
<tbody>
<tr>
<td class="post-excerpt" style="color:#0a0a0a;font-size:14px;font-weight:normal;padding:16px;text-align:<%= rtl? ? 'right' : 'left' %>;width:100%;">
- <%= email_excerpt(post.cooked) %>
+ <%= email_excerpt(post.cooked, post) %>
</td>
</tr>
</tbody>