diff --git a/app/mailers/user_notifications.rb b/app/mailers/user_notifications.rb index e1d085f5da2..79fd5d548fd 100644 --- a/app/mailers/user_notifications.rb +++ b/app/mailers/user_notifications.rb @@ -83,9 +83,14 @@ class UserNotifications < ActionMailer::Base return unless @posts_by_topic.present? build_summary_for(user) - apply_notification_styles build_email @user.email, + opts = { from_alias: I18n.t('user_notifications.mailing_list.from', site_name: SiteSetting.title), - subject: I18n.t('user_notifications.mailing_list.subject_template', site_name: @site_name, date: @date) + subject: I18n.t('user_notifications.mailing_list.subject_template', site_name: @site_name, date: @date), + mailing_list_mode: true, + add_unsubscribe_link: true, + unsubscribe_url: "#{Discourse.base_url}/email/unsubscribe/#{@unsubscribe_key}", + } + apply_notification_styles(build_email(@user.email, opts)) end def digest(user, opts={}) @@ -236,7 +241,6 @@ class UserNotifications < ActionMailer::Base end def self.get_context_posts(post, topic_user, user) - if user.user_option.email_previous_replies == UserOption.previous_replies_type[:never] return [] end @@ -376,7 +380,6 @@ class UserNotifications < ActionMailer::Base template << "_staged" if user.staged? end - email_opts = { topic_title: title, message: message, diff --git a/spec/mailers/user_notifications_spec.rb b/spec/mailers/user_notifications_spec.rb index 6f3dca0e741..bee8d13f25e 100644 --- a/spec/mailers/user_notifications_spec.rb +++ b/spec/mailers/user_notifications_spec.rb @@ -100,6 +100,7 @@ describe UserNotifications do expect(subject.from).to eq([SiteSetting.notification_email]) expect(subject.html_part.body.to_s).to include topic.title expect(subject.text_part.body.to_s).to be_present + expect(subject.header["List-Unsubscribe"].to_s).to match(/\/email\/unsubscribe\/\h{64}/) end it "includes posts less than 24 hours old" do