From a359a973e23cdc5878358e569e74e2a8bc72e7be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Mon, 11 Apr 2016 19:06:10 +0200 Subject: [PATCH] remove useless content when sending email to a staged used --- app/mailers/user_notifications.rb | 10 ++++++---- config/locales/server.en.yml | 11 ----------- lib/email/message_builder.rb | 2 +- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/app/mailers/user_notifications.rb b/app/mailers/user_notifications.rb index 1fa152df21a..c7c3832e4c2 100644 --- a/app/mailers/user_notifications.rb +++ b/app/mailers/user_notifications.rb @@ -207,10 +207,12 @@ class UserNotifications < ActionMailer::Base (user.locale.present? && I18n.available_locales.include?(user.locale.to_sym)) ? user.locale : nil end - def email_post_markdown(post) + def email_post_markdown(post, add_posted_by=false) result = "[email-indent]\n" result << "#{post.raw}\n\n" - result << "#{I18n.t('user_notifications.posted_by', username: post.username, post_date: post.created_at.strftime("%m/%d/%Y"))}\n\n" + if add_posted_by + result << "#{I18n.t('user_notifications.posted_by', username: post.username, post_date: post.created_at.strftime("%m/%d/%Y"))}\n\n" + end result << "[/email-indent]\n" result end @@ -315,7 +317,7 @@ class UserNotifications < ActionMailer::Base if context_posts.present? context << "-- \n*#{I18n.t('user_notifications.previous_discussion')}*\n" context_posts.each do |cp| - context << email_post_markdown(cp) + context << email_post_markdown(cp, true) end end @@ -378,7 +380,7 @@ class UserNotifications < ActionMailer::Base add_re_to_subject: add_re_to_subject, show_category_in_subject: show_category_in_subject, private_reply: post.topic.private_message?, - include_respond_instructions: !user.suspended?, + include_respond_instructions: !(user.suspended? || user.staged?), template: template, html_override: html, site_description: SiteSetting.site_description, diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index bf42176a4d2..019d997f584 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -2110,7 +2110,6 @@ en: %{message} - --- %{respond_instructions} user_invited_to_private_message_pm_staged: @@ -2120,7 +2119,6 @@ en: %{message} - --- %{respond_instructions} user_invited_to_topic: @@ -2130,7 +2128,6 @@ en: %{message} - --- %{respond_instructions} user_replied: @@ -2142,7 +2139,6 @@ en: %{context} - --- %{respond_instructions} user_replied_pm: @@ -2154,7 +2150,6 @@ en: %{context} - --- %{respond_instructions} user_quoted: @@ -2166,7 +2161,6 @@ en: %{context} - --- %{respond_instructions} user_linked: @@ -2178,7 +2172,6 @@ en: %{context} - --- %{respond_instructions} user_mentioned: @@ -2190,7 +2183,6 @@ en: %{context} - --- %{respond_instructions} user_group_mentioned: @@ -2202,7 +2194,6 @@ en: %{context} - --- %{respond_instructions} user_posted: @@ -2214,7 +2205,6 @@ en: %{context} - --- %{respond_instructions} user_posted_pm: @@ -2226,7 +2216,6 @@ en: %{context} - --- %{respond_instructions} user_posted_pm_staged: diff --git a/lib/email/message_builder.rb b/lib/email/message_builder.rb index 991620e3ad8..7d2c02280c7 100644 --- a/lib/email/message_builder.rb +++ b/lib/email/message_builder.rb @@ -39,7 +39,7 @@ module Email string = allow_reply_by_email? ? "user_notifications.reply_by_email" : "user_notifications.visit_link_to_respond" string << "_pm" if @opts[:private_reply] end - @template_args[:respond_instructions] = I18n.t(string, @template_args) + @template_args[:respond_instructions] = "---\n" + I18n.t(string, @template_args) end end end