Skip to content

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.rb
index 045f669ec03..9107101792f 100644
--- a/app/mailers/group_smtp_mailer.rb
+++ b/app/mailers/group_smtp_mailer.rb
@@ -64,7 +64,7 @@ class GroupSmtpMailer < ActionMailer::Base
context_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::Base
post.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}")
else
list.push("[#{u.username}](#{Discourse.base_url}/u/#{u.username_lower})")
end
else
if u.staged?
- list.push("[#{u.email}](#{Discourse.base_url}/u/#{u.username_lower})")
+ list.push("#{u.email}")
else
list.push("[#{u.name.blank? ? u.username : u.name}](#{Discourse.base_url}/u/#{u.username_lower})")
end
diff --git a/spec/jobs/regular/group_smtp_email_spec.rb b/spec/jobs/regular/group_smtp_email_spec.rb
index 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 do
fab!(:topic) { Fabricate(:private_message_topic, title: "Help I need support") }
fab!(:post) do
Fabricate(: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")
end
fab!(:group) { Fabricate(:smtp_group, name: "support-group", full_name: "Support Group") }
@@ -53,13 +54,26 @@ RSpec.describe Jobs::GroupSmtpEmail do
expect(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")
end
it "creates an EmailLog record with the correct details" do