FIX: convert emoji to unicode in topic titles in emails

This commit is contained in:
Neil Lalonde 2017-04-10 13:15:25 -04:00
parent 0013a23dc1
commit 3957540dd1
2 changed files with 7 additions and 6 deletions

View File

@ -4,6 +4,7 @@ require_dependency 'age_words'
class UserNotifications < ActionMailer::Base
include UserNotificationsHelper
include ApplicationHelper
helper :application
default charset: 'UTF-8'
@ -117,7 +118,7 @@ class UserNotifications < ActionMailer::Base
.for_mailing_list(user, min_date)
.where('posts.post_type = ?', Post.types[:regular])
.where('posts.deleted_at IS NULL AND posts.hidden = false AND posts.user_deleted = false')
.where("posts.post_number > ? AND posts.score > ?", 1, ScoreCalculator.default_score_weights[:like_score] * 5.0)
.where("posts.post_number > ? AND posts.score > ?", 1, ScoreCalculator.default_score_weights[:like_score] * 1.0)
.limit(SiteSetting.digest_posts)
else
[]
@ -399,7 +400,7 @@ class UserNotifications < ActionMailer::Base
invite_template = "user_notifications.invited_to_topic_body"
end
topic_excerpt = post.excerpt.tr("\n", " ") if post.is_first_post? && post.excerpt
message = I18n.t(invite_template, username: username, topic_title: title, topic_excerpt: topic_excerpt, site_title: SiteSetting.title, site_description: SiteSetting.site_description)
message = I18n.t(invite_template, username: username, topic_title: gsub_emoji_to_unicode(title), topic_excerpt: topic_excerpt, site_title: SiteSetting.title, site_description: SiteSetting.site_description)
unless translation_override_exists
html = UserNotificationRenderer.new(Rails.configuration.paths["app/views"]).render(
@ -434,7 +435,7 @@ class UserNotifications < ActionMailer::Base
end
email_opts = {
topic_title: title,
topic_title: gsub_emoji_to_unicode(title),
topic_title_url_encoded: title ? URI.encode(title) : title,
message: message,
url: post.url,

View File

@ -124,7 +124,7 @@ body, table, td, th, h1, h2, h3 {font-family: Helvetica, Arial, sans-serif !impo
<td style="padding: 0 8px 8px 16px; text-align:left; width:100%;">
<h2 style="font-size:18px;font-weight:400;line-height:1.3;margin:0;padding:0;word-wrap:normal">
<a href="<%= Discourse.base_url_no_prefix + t.relative_url %>" style="font-weight:400;line-height:1.3;margin:0;padding:0;text-decoration:none">
<strong><%= t.title.truncate(60, separator: /\s/) -%></strong>
<strong><%= gsub_emoji_to_unicode(t.title.truncate(60, separator: /\s/)) -%></strong>
</a>
</h2>
<%- if SiteSetting.show_topic_featured_link_in_digest && t.featured_link %>
@ -279,7 +279,7 @@ body, table, td, th, h1, h2, h3 {font-family: Helvetica, Arial, sans-serif !impo
</td>
<td style="color:#0a0a0a;line-height:1.3;padding:0 8px 8px 8px;text-align:right;">
<p style="color:#8f8f8f;line-height:1.3;margin:0 0 10px 0;padding:0;text-align:right;">
<a href="<%= post.full_url -%>" style="font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left;text-decoration:none"><%= post.topic.title.truncate(60, separator: /\s/) -%></a>
<a href="<%= post.full_url -%>" style="font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left;text-decoration:none"><%= gsub_emoji_to_unicode(post.topic.title.truncate(60, separator: /\s/)) -%></a>
</p>
<a href="<%= post.full_url -%>" class="with-accent-colors" style="width:100%;text-decoration:none;padding:8px 16px;white-space: nowrap;">
<%=t 'user_notifications.digest.join_the_discussion' %>
@ -325,7 +325,7 @@ body, table, td, th, h1, h2, h3 {font-family: Helvetica, Arial, sans-serif !impo
<tr style="vertical-align:top;">
<td style="padding:8px;text-align:left;">
<a href="<%= Discourse.base_url_no_prefix + t.relative_url %>" style="font-weight:400;line-height:1.3;margin:0;padding:0;text-decoration:none">
<strong><%= t.title.truncate(60, separator: /\s/) -%></strong>
<strong><%= gsub_emoji_to_unicode(t.title.truncate(60, separator: /\s/)) -%></strong>
</a>
<%- if SiteSetting.show_topic_featured_link_in_digest && t.featured_link %>
<a class='topic-featured-link' href='<%= t.featured_link %>'><%= raw topic_featured_link_domain(t.featured_link) %></a>