-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This removes various references to `ActionMailer` and the mailer classes since they are no longer being used as we're sending emails using the GOV.UK Notify API directly now (#2841). We can't remove the `ApplicationMailer` and stop requiring `action_mailer/railtie` until heartcombo/devise#5731 has been released.
- Loading branch information
Showing
21 changed files
with
15 additions
and
954 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,113 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class ApplicationMailer < Mail::Notify::Mailer | ||
before_action :attach_data_for_notify_log_entry | ||
after_deliver :log_delivery | ||
|
||
private | ||
|
||
def app_template_mail(template_name) | ||
template_mail( | ||
GOVUK_NOTIFY_EMAIL_TEMPLATES.fetch(template_name), | ||
to:, | ||
reply_to_id:, | ||
personalisation: | ||
) | ||
end | ||
|
||
def consent | ||
@consent ||= params[:consent] | ||
end | ||
|
||
def consent_form | ||
@consent_form ||= params[:consent_form] | ||
end | ||
|
||
def vaccination_record | ||
@vaccination_record ||= params[:vaccination_record] | ||
end | ||
|
||
def patient_session | ||
@patient_session ||= params[:patient_session] | ||
end | ||
|
||
def patient | ||
@patient ||= params[:patient] | ||
end | ||
|
||
def parent | ||
@parent ||= params[:parent] | ||
end | ||
|
||
def programme | ||
@programme ||= params[:programme] | ||
end | ||
|
||
def session | ||
@session ||= params[:session] | ||
end | ||
|
||
def sent_by | ||
@sent_by ||= params[:sent_by] | ||
end | ||
|
||
def to | ||
consent_form&.parent_email || consent&.parent&.email || parent.email | ||
end | ||
|
||
def reply_to_id | ||
team = | ||
session&.team || patient_session&.team || consent_form&.team || | ||
vaccination_record&.team | ||
|
||
return team.reply_to_id if team&.reply_to_id | ||
|
||
organisation = | ||
session&.organisation || patient_session&.organisation || | ||
consent_form&.organisation || consent&.organisation || | ||
vaccination_record&.organisation | ||
|
||
organisation.reply_to_id | ||
end | ||
|
||
def personalisation | ||
GovukNotifyPersonalisation.call( | ||
consent:, | ||
consent_form:, | ||
patient:, | ||
patient_session:, | ||
programme:, | ||
session:, | ||
vaccination_record: | ||
) | ||
end | ||
|
||
def attach_data_for_notify_log_entry | ||
# https://stackoverflow.com/a/28004917 | ||
|
||
patient_id = (patient || consent&.patient || patient_session&.patient)&.id | ||
consent_form_id = consent_form&.id | ||
|
||
message.instance_variable_set(:@consent_form_id, consent_form_id) | ||
message.instance_variable_set(:@patient_id, patient_id) | ||
message.instance_variable_set(:@sent_by_user_id, sent_by&.id) | ||
|
||
message.class.send(:attr_reader, :consent_form_id) | ||
message.class.send(:attr_reader, :patient_id) | ||
message.class.send(:attr_reader, :sent_by_user_id) | ||
end | ||
|
||
def log_delivery | ||
mail.to.map do |recipient| | ||
NotifyLogEntry.create!( | ||
consent_form_id: mail.consent_form_id, | ||
patient_id: mail.patient_id, | ||
recipient:, | ||
recipient_deterministic: recipient, | ||
sent_by_user_id: mail.sent_by_user_id, | ||
template_id: mail.template_id, | ||
type: :email | ||
) | ||
end | ||
end | ||
class ApplicationMailer < ActionMailer::Base | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,25 +36,6 @@ | |
# Store uploaded files on the local file system (see config/storage.yml for options). | ||
config.active_storage.service = :local | ||
|
||
# Don't care if the mailer can't send. | ||
config.action_mailer.raise_delivery_errors = false | ||
|
||
# Make template changes take effect immediately. | ||
config.action_mailer.perform_caching = false | ||
|
||
# Set localhost to be used by links generated in mailer templates. | ||
config.action_mailer.default_url_options = { host: "localhost", port: 4000 } | ||
|
||
if Settings.govuk_notify&.enabled | ||
config.action_mailer.delivery_method = :notify | ||
config.action_mailer.notify_settings = { | ||
api_key: Settings.govuk_notify["#{Settings.govuk_notify.mode}_key"] | ||
} | ||
else | ||
config.action_mailer.default_options = { from: "[email protected]" } | ||
config.action_mailer.delivery_method = :file | ||
end | ||
|
||
# Print deprecation notices to the Rails logger. | ||
config.active_support.deprecation = :log | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,15 +35,6 @@ | |
# Store uploaded files on the local file system in a temporary directory. | ||
config.active_storage.service = :test | ||
|
||
# Tell Action Mailer not to deliver emails to the real world. | ||
# The :test delivery method accumulates sent emails in the | ||
# ActionMailer::Base.deliveries array. | ||
config.action_mailer.delivery_method = :test | ||
|
||
# Set host to be used by links generated in mailer templates. | ||
config.action_mailer.default_url_options = { host: "localhost:4000" } | ||
config.action_mailer.default_options = { from: "[email protected]" } | ||
|
||
# Print deprecation notices to the stderr. | ||
config.active_support.deprecation = :stderr | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.