A platform for community discussion. Free, open, simple.
Fix missing topic link when private email enabled (#39667)
Juan David Martínez Cubillos1979c9ee1218
diff --git a/app/mailers/user_notifications.rb b/app/mailers/user_notifications.rbindex 97b3e0bfed0..fd002cf48d1 100644--- a/app/mailers/user_notifications.rb+++ b/app/mailers/user_notifications.rb@@ -750,9 +750,7 @@ class UserNotifications < ActionMailer::Baseendfirst_footer_classes = "highlight"- if (allow_reply_by_email && user.staged) || (user.suspended? || user.staged?)- first_footer_classes = ""- end+ first_footer_classes = "" if user.suspended? || (user.staged? && !SiteSetting.private_email?)unless translation_override_existshtml =@@ -786,7 +784,7 @@ class UserNotifications < ActionMailer::Basemailing_list_mode: user.user_option.mailing_list_mode,unsubscribe_url: post.unsubscribe_url(user),allow_reply_by_email: allow_reply_by_email,- only_reply_by_email: allow_reply_by_email && user.staged,+ only_reply_by_email: allow_reply_by_email && user.staged? && !SiteSetting.private_email?,use_site_subject: use_site_subject,add_re_to_subject: add_re_to_subject,show_category_in_subject: show_category_in_subject,@@ -794,7 +792,8 @@ class UserNotifications < ActionMailer::Baseprivate_reply: post.topic.private_message?,subject_pm: subject_pm,participants: participants,- include_respond_instructions: !(user.suspended? || user.staged?),+ include_respond_instructions:+ !(user.suspended? || (user.staged? && !SiteSetting.private_email?)),notification_type: notification_type,template: template,use_topic_title_subject: use_topic_title_subject,diff --git a/config/locales/server.en.yml b/config/locales/server.en.ymlindex 7d6ca4724e1..5005b65198e 100644--- a/config/locales/server.en.yml+++ b/config/locales/server.en.yml@@ -4821,6 +4821,8 @@ en:%{message}+ %{respond_instructions}+account_suspended:title: "Account Suspended"subject_template: "[%{email_prefix}] Your account has been suspended"diff --git a/spec/mailers/user_notifications_spec.rb b/spec/mailers/user_notifications_spec.rbindex 8c186b43dd5..3069521f7d7 100644--- a/spec/mailers/user_notifications_spec.rb+++ b/spec/mailers/user_notifications_spec.rb@@ -1158,7 +1158,7 @@ RSpec.describe UserNotifications doshared_examples "respect for private_email" docontext "with private_email" do- it "doesn't support reply by email" do+ it "doesn't include topic title or slug for regular users" doSiteSetting.private_email = truemailer =@@ -1177,6 +1177,35 @@ RSpec.describe UserNotifications doexpect(message.text_part.body.to_s).not_to include(topic.title)expect(message.text_part.body.to_s).not_to include(topic.slug)end++ it "still links back to the topic for staged users" do+ skip_types = %i[linked quoted mentioned group_mentioned]+ if skip_types.include?(notification_type)+ skip "Staged users don't receive #{notification_type} emails"+ end++ invite_types = %i[invited_to_private_message invited_to_topic watching_first_post]+ if invite_types.include?(notification_type)+ skip "Invite-type emails use a different template structure"+ end++ SiteSetting.private_email = true+ user.update!(staged: true)++ mailer =+ UserNotifications.public_send(+ mail_type,+ user,+ notification_type: Notification.types[notification.notification_type],+ notification_data_hash: notification.data_hash,+ post: notification.post,+ )+ message = mailer.message++ slugless_path = notification.post.topic.slugless_url+ expect(message.html_part.body.to_s).to include(slugless_path)+ expect(message.text_part.body.to_s).to include(slugless_path)+ endendend