Skip to content

Commit

Permalink
Add developer notes regarding Notify mailer (#1222)
Browse files Browse the repository at this point in the history
* Add developer notes regarding Notify mailer

* Additional comments

* Note update

---------

Co-authored-by: Katherine Martin <[email protected]>
  • Loading branch information
peterdavidhamilton and martikat authored Jul 2, 2024
1 parent 6969c7c commit f690ae6
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/jobs/complete_registration_mail_job.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Sends mail for complete registration
# @note email delivery is queued unless DELIVERY_QUEUE=false
class CompleteRegistrationMailJob < MailJob
def run
super do
Expand Down
2 changes: 2 additions & 0 deletions app/jobs/continue_training_mail_job.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Sends mail for continue training for a module
# @note email delivery is queued unless DELIVERY_QUEUE=false
class ContinueTrainingMailJob < MailJob
def run
super do
Expand Down
2 changes: 2 additions & 0 deletions app/jobs/start_training_mail_job.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Sends mail for start training
# @note email delivery is queued unless DELIVERY_QUEUE=false
class StartTrainingMailJob < MailJob
def run
super do
Expand Down
1 change: 1 addition & 0 deletions app/jobs/test_bulk_mail_job.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Simple background job using a dummy template
# @note email delivery is queued unless DELIVERY_QUEUE=false
class TestBulkMailJob < MailJob
# @note guard clause prevents testing against production data
#
Expand Down
7 changes: 7 additions & 0 deletions app/mailers/notify_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ def new_module(user, mod)

private

# @note
# Avoid deploying mailer changes when scheduled mail jobs will run.
#
# Background worker deployment is not gated therefore database migrations
# that impact after_deliver callbacks can potentially raise errors until the
# web app is released.
#
# @return [MailEvent, nil]
def log_delivery
if (user = User.find_by(email: Array(message.to).first))
Expand Down
1 change: 1 addition & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class Application < Rails::Application

# Notify
config.notify_token = ENV.fetch('GOVUK_NOTIFY_API_KEY', credentials.notify_api_key)
# @note Nudge mail must only run once per day
config.mail_job_interval = ENV.fetch('MAIL_JOB_INTERVAL', '0 12 * * *') # Noon daily

config.user_password = ENV.fetch('USER_PASSWORD', 'Str0ngPa$$w0rd12')
Expand Down

0 comments on commit f690ae6

Please sign in to comment.