mirror of
https://github.com/discourse/discourse.git
synced 2026-09-05 04:40:41 -05:00
Fix missing topic link when private email enabled (#39667)
#### Description Currently, staged users with `private_email enabled` receive emails without any content or link to the topic the conversation is taking place on, making it impossible to navigate to it. This PR adds the response instruction section, which contains the `topic_url` when this happens, so staged users can visit the topic. meta: [/t/401078](https://meta.discourse.org/t/with-private-email-enabled-we-should-still-link-the-topic-in-outgoing-emails/401078) --------- Co-authored-by: Bannon Tanner <bannon@discourse.org>
This commit is contained in:
co-authored by
Bannon Tanner
parent
6214354bbd
commit
1979c9ee12
@@ -750,9 +750,7 @@ class UserNotifications < ActionMailer::Base
|
||||
end
|
||||
|
||||
first_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_exists
|
||||
html =
|
||||
@@ -786,7 +784,7 @@ class UserNotifications < ActionMailer::Base
|
||||
mailing_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::Base
|
||||
private_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,
|
||||
|
||||
@@ -4821,6 +4821,8 @@ en:
|
||||
|
||||
%{message}
|
||||
|
||||
%{respond_instructions}
|
||||
|
||||
account_suspended:
|
||||
title: "Account Suspended"
|
||||
subject_template: "[%{email_prefix}] Your account has been suspended"
|
||||
|
||||
@@ -1158,7 +1158,7 @@ RSpec.describe UserNotifications do
|
||||
|
||||
shared_examples "respect for private_email" do
|
||||
context "with private_email" do
|
||||
it "doesn't support reply by email" do
|
||||
it "doesn't include topic title or slug for regular users" do
|
||||
SiteSetting.private_email = true
|
||||
|
||||
mailer =
|
||||
@@ -1177,6 +1177,35 @@ RSpec.describe UserNotifications do
|
||||
expect(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)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user