From 5c7d6e0a3c4507d06f79450d87a4323afd7c492b Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Wed, 22 Apr 2015 16:15:23 -0400 Subject: [PATCH] FIX: Don't display names on emails if `display_name_on_posts` is false Note that `enable_names` was always respected. --- app/helpers/user_notifications_helper.rb | 7 +++++++ app/views/email/_post.html.erb | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/helpers/user_notifications_helper.rb b/app/helpers/user_notifications_helper.rb index 77dea02d7..05df6b129 100644 --- a/app/helpers/user_notifications_helper.rb +++ b/app/helpers/user_notifications_helper.rb @@ -54,6 +54,13 @@ module UserNotificationsHelper raw format_for_email(html) end + def show_name_on_post(post) + SiteSetting.enable_names? && + SiteSetting.display_name_on_posts? && + post.user.name.present? && + post.user.name != post.user.username + end + def format_for_email(html) PrettyText.format_for_email(html).html_safe end diff --git a/app/views/email/_post.html.erb b/app/views/email/_post.html.erb index 122df1af5..48da134ce 100644 --- a/app/views/email/_post.html.erb +++ b/app/views/email/_post.html.erb @@ -6,7 +6,7 @@ <%= post.user.username %> - <%- if SiteSetting.enable_names? && post.user.name.present? && post.user.name != post.user.username %> + <%- if show_name_on_post(post) %> <%= post.user.name %> <% end %> <%- if post.user.title.present? %>