FIX: respect private_email setting for user invited notification email

FIX: respect private_email setting for user invited notification email

diff --git a/app/mailers/user_notifications.rb b/app/mailers/user_notifications.rb
index e74c94e8e2..bdf9c85698 100644
--- a/app/mailers/user_notifications.rb
+++ b/app/mailers/user_notifications.rb
@@ -558,7 +558,12 @@ class UserNotifications < ActionMailer::Base
         end
 
       topic_excerpt = post.excerpt.tr("\n", " ") if post.is_first_post? && post.excerpt
-      topic_excerpt = "" if SiteSetting.private_email?
+      topic_url = post.topic&.url
+
+      if SiteSetting.private_email?
+        topic_excerpt = ""
+        topic_url = ""
+      end
 
       message = I18n.t(invite_template,
         username: username,
@@ -567,7 +572,7 @@ class UserNotifications < ActionMailer::Base
         topic_excerpt: topic_excerpt,
         site_title: SiteSetting.title,
         site_description: SiteSetting.site_description,
-        topic_url: post.topic.url
+        topic_url: topic_url
       )
 
       html = PrettyText.cook(message, sanitize: false).html_safe

GitHub sha: c596d7df

1 Like