Class: PrivacyMailer

Inherits:
ApplicationMailer show all
Defined in:
app/mailers/privacy_mailer.rb

Overview

ActionMailer: privacy.

Sends the four notifications that drive the privacy deletion request
lifecycle:

  • #deletion_request_received — team alert on intake. Fires for every
    request the moment the row is created so on-call has eyes on it.
  • #held_for_review — team alert when Privacy::ManualReviewDetector
    triggers a Tier-3 hold. Includes the reason payload so a reviewer can
    triage from the email.
  • #failed — team alert when Privacy::DataDeletionWorker or
    Privacy::ScrubService hits an unexpected error. Links to the admin
    review page where it can be retried.
  • #completed — user-facing confirmation, mirrors the template in
    doc/operations/PRIVACY_REQUESTS_RUNBOOK.md §10. From
    privacy@warmlyyours.com (not heatwave-team) so the recipient sees a
    sender consistent with where they originally wrote.

Constant Summary collapse

TEAM_RECIPIENT =
'heatwaveteam@warmlyyours.com'
TEAM_FROM =
'Heatwave Team <heatwaveteam@warmlyyours.com>'
USER_FACING_FROM =
'WarmlyYours Privacy <privacy@warmlyyours.com>'

Instance Method Summary collapse

Methods inherited from ApplicationMailer

#null_mail

Instance Method Details

#completed(deletion_request) ⇒ Object



44
45
46
47
48
49
50
51
# File 'app/mailers/privacy_mailer.rb', line 44

def completed(deletion_request)
  @request = deletion_request
  recipient = recipient_for_completion(deletion_request)
  return null_mail if recipient.blank?

  mail(from: USER_FACING_FROM, to: recipient,
       subject: "Your privacy request is complete — ##{@request.id}")
end

#deletion_request_received(deletion_request) ⇒ Object



25
26
27
28
29
# File 'app/mailers/privacy_mailer.rb', line 25

def deletion_request_received(deletion_request)
  @request = deletion_request
  mail(from: TEAM_FROM, to: TEAM_RECIPIENT,
       subject: "[Privacy] New deletion request received — ##{@request.id} (#{@request.source})")
end

#failed(deletion_request) ⇒ Object



38
39
40
41
42
# File 'app/mailers/privacy_mailer.rb', line 38

def failed(deletion_request)
  @request = deletion_request
  mail(from: TEAM_FROM, to: TEAM_RECIPIENT,
       subject: "[Privacy] Deletion request ##{@request.id} FAILED — needs investigation")
end

#held_for_review(deletion_request) ⇒ Object



31
32
33
34
35
36
# File 'app/mailers/privacy_mailer.rb', line 31

def held_for_review(deletion_request)
  @request = deletion_request
  @reasons = @request.manual_review_reason
  mail(from: TEAM_FROM, to: TEAM_RECIPIENT,
       subject: "[Privacy] Deletion request ##{@request.id} HELD FOR REVIEW")
end