emails: include logging information in email headers.

Log the following information in email headers:

* X-Danbooru-User: the user's name and ID.
* X-Danbooru-IP: the user's IP.
* X-Danbooru-Session: the users' session ID.
* X-Danbooru-URL: the page that triggered the email.
* X-Danbooru-Job-Id: the ID of the background job that sent the email.
* X-Danbooru-Enqueued-At: when the email was queued as a background job.
* X-Danbooru-Dmail: for Dmail notifications, the link to the Dmail.
* X-Request-Id: the request ID of the HTTP request that triggered the email.

Also make it so we log an event in the APM when we send an email.
This commit is contained in:
evazion
2022-09-28 20:16:50 -05:00
parent ed9986def6
commit b94cb7d824
14 changed files with 93 additions and 11 deletions

View File

@@ -146,7 +146,7 @@ class Dmail < ApplicationRecord
def send_email
if is_recipient? && !is_deleted? && to.receive_email_notifications?
UserMailer.dmail_notice(self).deliver_later
UserMailer.with(headers: { "X-Danbooru-Dmail": Routes.dmail_url(self) }).dmail_notice(self).deliver_later
end
end

View File

@@ -379,7 +379,7 @@ class User < ApplicationRecord
if errors.none?
UserEvent.create_from_request!(self, :email_change, request)
UserMailer.email_change_confirmation(self).deliver_later
UserMailer.with_request(request).email_change_confirmation(self).deliver_later
end
end
end