Skip to content

Commit f52121e

Browse files
committed
Include person_name in notify jobs and fix ENV key
Pass user.name through controllers and services into SendEmailVerificationJob and SendConfirmEmailVerificationJob, add person_name to Notify template vars so emails can include the recipient's name, and update SendConfirmEmailVerificationJob signature. Also correct the Notify client initializer to use ENV['GOV_NOTIFY_API_KEY'] (was GOVUK_NOTIFY_API_KEY).
1 parent 05ca9f0 commit f52121e

6 files changed

Lines changed: 14 additions & 10 deletions

File tree

app/controllers/v1/email_verifications_controller.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ def create
1111
if verification_request.save
1212

1313
SendEmailVerificationJob.perform_later(
14-
email: new_email,
15-
verification_url: verification_request.verification_url
14+
new_email: new_email,
15+
verification_url: verification_request.verification_url,
16+
person_name: user.name
1617
)
1718

1819
render jsonapi: verification_request, status: :ok, context: { request: request }

app/controllers/v1/users_controller.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ def update_email
3131

3232
if verification_request.save
3333
notify_result = SendEmailVerificationJob.perform_later(
34-
email: new_email,
35-
verification_url: verification_request.verification_url
34+
new_email: new_email,
35+
verification_url: verification_request.verification_url,
36+
person_name: user.name
3637
)
3738

3839
if notify_result == false

app/jobs/send_confirm_email_verification_job.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ class SendConfirmEmailVerificationJob < ApplicationJob
33

44
TEMPLATE_ID = '59cda9d1-9a70-4196-8b50-fba71e410765'.freeze
55

6-
def perform(new_email:)
6+
def perform(new_email:, person_name: nil)
77
Notify.new.send_email(
88
template_id: TEMPLATE_ID,
99
email: new_email,
1010
vars: {
1111
login_url: ENV['FRONTEND_URL'],
12-
email_address: new_email
12+
email_address: new_email,
13+
person_name: person_name
1314
}
1415
)
1516
end

app/jobs/send_email_verification_job.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ class SendEmailVerificationJob < ApplicationJob
33

44
TEMPLATE_ID = '26164cdb-915b-4e13-97e9-d4a42367f068'.freeze
55

6-
def perform(new_email:, verification_url:)
6+
def perform(new_email:, verification_url:, person_name: nil)
77
Notify.new.send_email(
88
template_id: TEMPLATE_ID,
99
email: new_email,
1010
vars: {
1111
verify_url: verification_url,
12-
new_email: new_email
12+
new_email: new_email,
13+
person_name: person_name
1314
}
1415
)
1516
end

app/services/notify.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class Notify
44
def initialize
5-
@client = Notifications::Client.new(ENV['GOVUK_NOTIFY_API_KEY'])
5+
@client = Notifications::Client.new(ENV['GOV_NOTIFY_API_KEY'])
66
end
77

88
def send_email(template_id:, email:, vars: {})

app/services/update_user_email.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def update_user_record
2525

2626
def sync_with_auth0
2727
UpdateUserEmailInAuth0.new(user: @user).call
28-
SendConfirmEmailVerificationJob.perform_later(new_email: @new_email)
28+
SendConfirmEmailVerificationJob.perform_later(new_email: @new_email, person_name: @user.name)
2929
rescue Auth0::Exception => e
3030
errors.add(:base, "Auth0 update failed: #{e.message}")
3131
Rails.logger.error("Auth0 Error: #{e.message}")

0 commit comments

Comments
 (0)