A platform for community discussion. Free, open, simple.
FIX: Do not show In Reply To for group SMTP emails (#13541)
Martin Brennan4d0178deab85
diff --git a/app/mailers/group_smtp_mailer.rb b/app/mailers/group_smtp_mailer.rbindex 045f669ec03..9107101792f 100644--- a/app/mailers/group_smtp_mailer.rb+++ b/app/mailers/group_smtp_mailer.rb@@ -64,7 +64,7 @@ class GroupSmtpMailer < ActionMailer::Basecontext_posts: nil,reached_limit: nil,post: post,- in_reply_to_post: post.reply_to_post,+ in_reply_to_post: nil,classes: Rtl.new(nil).css_class,first_footer_classes: '',reply_above_line: true@@ -82,13 +82,13 @@ class GroupSmtpMailer < ActionMailer::Basepost.topic.allowed_users.each do |u|if SiteSetting.prioritize_username_in_ux?if u.staged?- list.push("[#{u.email}](#{Discourse.base_url}/u/#{u.username_lower})")+ list.push("#{u.email}")elselist.push("[#{u.username}](#{Discourse.base_url}/u/#{u.username_lower})")endelseif u.staged?- list.push("[#{u.email}](#{Discourse.base_url}/u/#{u.username_lower})")+ list.push("#{u.email}")elselist.push("[#{u.name.blank? ? u.username : u.name}](#{Discourse.base_url}/u/#{u.username_lower})")enddiff --git a/spec/jobs/regular/group_smtp_email_spec.rb b/spec/jobs/regular/group_smtp_email_spec.rbindex 1bcae95af06..8e24ac7eeff 100644--- a/spec/jobs/regular/group_smtp_email_spec.rb+++ b/spec/jobs/regular/group_smtp_email_spec.rb@@ -6,6 +6,7 @@ RSpec.describe Jobs::GroupSmtpEmail dofab!(:topic) { Fabricate(:private_message_topic, title: "Help I need support") }fab!(:post) doFabricate(:post, topic: topic, raw: "some first post content")+ Fabricate(:post, topic: topic, raw: "some intermediate content")Fabricate(:post, topic: topic, raw: "this is the second post reply")endfab!(:group) { Fabricate(:smtp_group, name: "support-group", full_name: "Support Group") }@@ -53,13 +54,26 @@ RSpec.describe Jobs::GroupSmtpEmail doexpect(email_log.as_mail_message.text_part.to_s).not_to include("some first post content")end- it "includes the participants in the correct format" do+ it "does not include in reply to post in email but still has the header" do+ second_post = topic.posts.find_by(post_number: 2)+ post.update!(reply_to_post_number: 1, reply_to_user: second_post.user)+ PostReply.create(post: second_post, reply: post)subject.execute(args)email_log = EmailLog.find_by(post_id: post.id, topic_id: post.topic_id, user_id: recipient_user.id)- expect(email_log.as_mail_message.text_part.to_s).to include("Support Group")- expect(email_log.as_mail_message.text_part.to_s).to include("[email protected]")- expect(email_log.as_mail_message.text_part.to_s).to include("[email protected]")- expect(email_log.as_mail_message.text_part.to_s).to include("normaluser")+ expect(email_log.raw_headers).to include("In-Reply-To: <topic/#{post.topic_id}/#{second_post.id}@#{Email::Sender.host_for(Discourse.base_url)}>")+ expect(email_log.as_mail_message.html_part.to_s).not_to include(I18n.t("user_notifications.in_reply_to"))+ end++ it "includes the participants in the correct format, and does not have links for the staged users" do+ subject.execute(args)+ email_log = EmailLog.find_by(post_id: post.id, topic_id: post.topic_id, user_id: recipient_user.id)+ email_text = email_log.as_mail_message.text_part.to_s+ expect(email_text).to include("Support Group")+ expect(email_text).to include("[email protected]")+ expect(email_text).not_to include("[[email protected]]")+ expect(email_text).to include("[email protected]")+ expect(email_text).not_to include("[[email protected]]")+ expect(email_text).to include("normaluser")endit "creates an EmailLog record with the correct details" do