FIX: Do not show In Reply To for group SMTP emails (#13541)

We do not want to show the In Reply To section of the
group SMTP email template, it is similar to Context Posts
which we removed and is unnecessary.

This PR also removes the link to staged user profiles in
the email; their email addresses will just be converted
to regular mailto: links.
This commit is contained in:
Martin Brennan 2021-06-28 13:19:17 +10:00 committed by GitHub
parent fd8016d678
commit 4d0178deab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 8 deletions

View File

@ -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

View File

@ -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("otherguy@test.com")
expect(email_log.as_mail_message.text_part.to_s).to include("cormac@lit.com")
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("otherguy@test.com")
expect(email_text).not_to include("[otherguy@test.com]")
expect(email_text).to include("cormac@lit.com")
expect(email_text).not_to include("[cormac@lit.com]")
expect(email_text).to include("normaluser")
end
it "creates an EmailLog record with the correct details" do