Fix #4515: Set List-Unsubscribe header on notification emails.

This commit is contained in:
evazion
2022-01-02 16:33:45 -06:00
parent 27ed41437c
commit e40218d1c8
5 changed files with 11 additions and 6 deletions

View File

@@ -4,9 +4,14 @@
#
# @see https://guides.rubyonrails.org/action_mailer_basics.html
class ApplicationMailer < ActionMailer::Base
helper :application
helper :users
include UsersHelper
default from: "#{Danbooru.config.canonical_app_name} <#{Danbooru.config.contact_email}>", content_type: "text/html"
def mail(user, require_verified_email:, **options)
headers["List-Unsubscribe"] = disable_email_notifications_url(user)
message = super(to: user.email_address&.address, **options)
message.perform_deliveries = user.can_receive_email?(require_verified_email: require_verified_email)
message

View File

@@ -1,9 +1,6 @@
# frozen_string_literal: true
class UserMailer < ApplicationMailer
helper :application
helper :users
# The email sent when a user receives a DMail.
def dmail_notice(dmail)
@dmail = dmail