From 2c7533d56fea98db3e13e9a1f0a69d9e10803ecb Mon Sep 17 00:00:00 2001 From: JackRyan1989 Date: Fri, 27 Oct 2023 10:06:47 -0400 Subject: [PATCH 01/10] Update job to send enrollment code to pinpoint message. and have translation display that message. --- app/jobs/in_person/send_proofing_notification_job.rb | 1 + config/locales/telephony/en.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/jobs/in_person/send_proofing_notification_job.rb b/app/jobs/in_person/send_proofing_notification_job.rb index d8d30952fc0..3bd2d477d27 100644 --- a/app/jobs/in_person/send_proofing_notification_job.rb +++ b/app/jobs/in_person/send_proofing_notification_job.rb @@ -81,6 +81,7 @@ def notification_message(enrollment:) app_name: APP_NAME, proof_date: proof_date, contact_number: IdentityConfig.store.idv_contact_phone_number, + reference_string: enrollment.enrollment_code, ) end end diff --git a/config/locales/telephony/en.yml b/config/locales/telephony/en.yml index eb0b8cdd769..8f903b97cd4 100644 --- a/config/locales/telephony/en.yml +++ b/config/locales/telephony/en.yml @@ -15,7 +15,7 @@ en: code expires in %{expiration} minutes. confirmation_ipp_enrollment_result: sms: |- - %{app_name}: You visited the Post Office on %{proof_date}. Check email for your result. Not you? Report this right away: %{contact_number} + %{app_name}: You visited the Post Office on %{proof_date}. Check email for your result. Not you? Report this right away: %{contact_number}. Ref: %{reference_string} confirmation_otp: sms: |- %{app_name}: Your one-time code is %{code}. It expires in %{expiration} minutes. Don't share this code with anyone. From 06ece3236af9a1f39c409d98a614ad445a817aae Mon Sep 17 00:00:00 2001 From: JackRyan1989 Date: Fri, 27 Oct 2023 10:15:12 -0400 Subject: [PATCH 02/10] Updates to spanish and french translations to incorporate reference code. --- config/locales/telephony/es.yml | 2 +- config/locales/telephony/fr.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/locales/telephony/es.yml b/config/locales/telephony/es.yml index 8be4d787dad..b6d1a123e06 100644 --- a/config/locales/telephony/es.yml +++ b/config/locales/telephony/es.yml @@ -15,7 +15,7 @@ es: Este código expira en %{expiration} minutos. confirmation_ipp_enrollment_result: sms: |- - %{app_name}: Visitó la oficina de correos el %{proof_date}. Revise su correo electrónico para ver su resultado. ¿No fue usted? Informe ahora mismo: %{contact_number} + %{app_name}: Visitó la oficina de correos el %{proof_date}. Revise su correo electrónico para ver su resultado. ¿No fue usted? Informe ahora mismo: %{contact_number}. Ref: %{reference_string} confirmation_otp: sms: |- %{app_name}: La contraseña es %{code}. Esta contraseña puede usarse una vez y se vence en %{expiration} minutos. No la comparta con nadie. diff --git a/config/locales/telephony/fr.yml b/config/locales/telephony/fr.yml index b1428880d30..0c703caadf7 100644 --- a/config/locales/telephony/fr.yml +++ b/config/locales/telephony/fr.yml @@ -16,7 +16,7 @@ fr: minutes. confirmation_ipp_enrollment_result: sms: |- - %{app_name}: Vous avez visité le bureau de poste le %{proof_date}. Vérifiez votre e-mail pour votre résultat. Ce n'est pas vous? Signalez-le immédiatement: %{contact_number} + %{app_name}: Vous avez visité le bureau de poste le %{proof_date}. Vérifiez votre e-mail pour votre résultat. Ce n'est pas vous? Signalez-le immédiatement: %{contact_number}. Réf: %{reference_number} confirmation_otp: sms: |- %{app_name}: Votre code à usage unique est %{code}. Il est valable pendant %{expiration} minutes. Vous ne devez pas partager ce code avec personne. From 0d7f7f902308f4e75265c6fe45c2bf8b645724c1 Mon Sep 17 00:00:00 2001 From: JackRyan1989 Date: Fri, 27 Oct 2023 15:13:16 -0400 Subject: [PATCH 03/10] Updating notification test. Wanna see what gitlab does --- spec/jobs/in_person/send_proofing_notification_job_spec.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/jobs/in_person/send_proofing_notification_job_spec.rb b/spec/jobs/in_person/send_proofing_notification_job_spec.rb index 48d98abda68..0cf4d2a77c4 100644 --- a/spec/jobs/in_person/send_proofing_notification_job_spec.rb +++ b/spec/jobs/in_person/send_proofing_notification_job_spec.rb @@ -12,6 +12,7 @@ :passed, :with_notification_phone_configuration, proofed_at: Time.zone.now - 3.days, + enrollment_code: '1234567890123456', ) end let(:failing_enrollment) do @@ -153,6 +154,7 @@ proofed_date = Time.zone.now.strftime('%m/%d/%Y') phone_number = passed_enrollment.notification_phone_configuration.formatted_phone contact_number = '(844) 555-5555' + reference_string = passed_enrollment.enrollment_code expect(Telephony). to( @@ -160,8 +162,8 @@ with( to: phone_number, message: "Login.gov: Vous avez visité le bureau de poste le #{proofed_date}." \ - " Vérifiez votre e-mail pour votre résultat. Ce n'est pas vous?" \ - " Signalez-le immédiatement: #{contact_number}", + " Vérifiez votre e-mail pour votre résultat. Ce n'est pas vous?" \ + " Signalez-le immédiatement: #{contact_number}. Réf: #{reference_string}", country_code: Phonelib.parse(phone_number).country, ), ) From 91e20a37e274adad3a7c6695dfc47fd37509dcbb Mon Sep 17 00:00:00 2001 From: JackRyan1989 Date: Mon, 30 Oct 2023 12:04:20 -0400 Subject: [PATCH 04/10] Fixing var name in french translation --- config/locales/telephony/fr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/telephony/fr.yml b/config/locales/telephony/fr.yml index 0c703caadf7..5ddb9fec2f7 100644 --- a/config/locales/telephony/fr.yml +++ b/config/locales/telephony/fr.yml @@ -16,7 +16,7 @@ fr: minutes. confirmation_ipp_enrollment_result: sms: |- - %{app_name}: Vous avez visité le bureau de poste le %{proof_date}. Vérifiez votre e-mail pour votre résultat. Ce n'est pas vous? Signalez-le immédiatement: %{contact_number}. Réf: %{reference_number} + %{app_name}: Vous avez visité le bureau de poste le %{proof_date}. Vérifiez votre e-mail pour votre résultat. Ce n'est pas vous? Signalez-le immédiatement: %{contact_number}. Réf: %{reference_string} confirmation_otp: sms: |- %{app_name}: Votre code à usage unique est %{code}. Il est valable pendant %{expiration} minutes. Vous ne devez pas partager ce code avec personne. From b472403083cfdf4cf35fc6fde464059dfece0a50 Mon Sep 17 00:00:00 2001 From: JackRyan1989 Date: Mon, 30 Oct 2023 12:20:56 -0400 Subject: [PATCH 05/10] changelog: User-facing changes, In-person proofing, attach enrollment code to SMS message for reference during possible fraud From d36f81227326049c6dc8c5c30ab4cec09c42f9ce Mon Sep 17 00:00:00 2001 From: JackRyan1989 Date: Mon, 30 Oct 2023 13:51:51 -0400 Subject: [PATCH 06/10] changelog: User-Facing Improvements, In-Person Proofing, attach enrollment code to SMS message for reference during possible fraud From 9369c09d714a629d8fedee9260d1305f77c17061 Mon Sep 17 00:00:00 2001 From: JackRyan1989 Date: Tue, 31 Oct 2023 12:12:43 -0400 Subject: [PATCH 07/10] Adding tests for english, spanish and french languages for SMS response --- .../send_proofing_notification_job_spec.rb | 84 ++++++++++++++----- 1 file changed, 64 insertions(+), 20 deletions(-) diff --git a/spec/jobs/in_person/send_proofing_notification_job_spec.rb b/spec/jobs/in_person/send_proofing_notification_job_spec.rb index 0cf4d2a77c4..b65e6197424 100644 --- a/spec/jobs/in_person/send_proofing_notification_job_spec.rb +++ b/spec/jobs/in_person/send_proofing_notification_job_spec.rb @@ -146,29 +146,73 @@ end end - it 'sends a message that respects the user email locale preference' do - allow(Telephony).to receive(:send_notification).and_return(sms_success_response) + context 'sends a message that respects the user email locale preference' do + let(:proofed_date) { Time.zone.now.strftime('%m/%d/%Y') } + let(:phone_number) { passed_enrollment.notification_phone_configuration.formatted_phone } + let(:contact_number) { '(844) 555-5555' } + let(:reference_string) { passed_enrollment.enrollment_code } - passed_enrollment.user.update!(email_language: 'fr') - passed_enrollment.update!(proofed_at: Time.zone.now) - proofed_date = Time.zone.now.strftime('%m/%d/%Y') - phone_number = passed_enrollment.notification_phone_configuration.formatted_phone - contact_number = '(844) 555-5555' - reference_string = passed_enrollment.enrollment_code + before do + allow(Telephony).to receive(:send_notification).and_return(sms_success_response) + end - expect(Telephony). - to( - receive(:send_notification). - with( - to: phone_number, - message: "Login.gov: Vous avez visité le bureau de poste le #{proofed_date}." \ - " Vérifiez votre e-mail pour votre résultat. Ce n'est pas vous?" \ - " Signalez-le immédiatement: #{contact_number}. Réf: #{reference_string}", - country_code: Phonelib.parse(phone_number).country, - ), - ) + it 'handles English language preference' do + passed_enrollment.user.update!(email_language: 'en') + passed_enrollment.update!(proofed_at: Time.zone.now) - job.perform(passed_enrollment.id) + expect(Telephony). + to( + receive(:send_notification). + with( + to: phone_number, + message: "Login.gov: You visited the Post Office on #{proofed_date}." \ + " Check email for your result. Not you? Report this right away: #{contact_number}." \ + " Ref: #{reference_string}", + country_code: Phonelib.parse(phone_number).country, + ), + ) + + job.perform(passed_enrollment.id) + end + + + it 'handles French language preference' do + passed_enrollment.user.update!(email_language: 'fr') + passed_enrollment.update!(proofed_at: Time.zone.now) + + expect(Telephony). + to( + receive(:send_notification). + with( + to: phone_number, + message: "Login.gov: Vous avez visité le bureau de poste le #{proofed_date}." \ + " Vérifiez votre e-mail pour votre résultat. Ce n'est pas vous?" \ + " Signalez-le immédiatement: #{contact_number}. Réf: #{reference_string}", + country_code: Phonelib.parse(phone_number).country, + ), + ) + + job.perform(passed_enrollment.id) + end + + it 'handles Spanish language preference' do + passed_enrollment.user.update!(email_language: 'es') + passed_enrollment.update!(proofed_at: Time.zone.now) + + expect(Telephony). + to( + receive(:send_notification). + with( + to: phone_number, + message: "Login.gov: Visitó la oficina de correos el #{proofed_date}." \ + " Revise su correo electrónico para ver su resultado. ¿No fue usted?" \ + " Informe ahora mismo: #{contact_number}. Ref: #{reference_string}", + country_code: Phonelib.parse(phone_number).country, + ), + ) + + job.perform(passed_enrollment.id) + end end end From 4731859d618416259fc35f40c3fb7d696092fa26 Mon Sep 17 00:00:00 2001 From: JackRyan1989 Date: Tue, 31 Oct 2023 12:19:54 -0400 Subject: [PATCH 08/10] Linting --- .../send_proofing_notification_job_spec.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/jobs/in_person/send_proofing_notification_job_spec.rb b/spec/jobs/in_person/send_proofing_notification_job_spec.rb index b65e6197424..7af5bcb2cbc 100644 --- a/spec/jobs/in_person/send_proofing_notification_job_spec.rb +++ b/spec/jobs/in_person/send_proofing_notification_job_spec.rb @@ -166,16 +166,16 @@ with( to: phone_number, message: "Login.gov: You visited the Post Office on #{proofed_date}." \ - " Check email for your result. Not you? Report this right away: #{contact_number}." \ + " Check email for your result." \ + " Not you? Report this right away: #{contact_number}." \ " Ref: #{reference_string}", country_code: Phonelib.parse(phone_number).country, - ), - ) + ), + ) job.perform(passed_enrollment.id) end - it 'handles French language preference' do passed_enrollment.user.update!(email_language: 'fr') passed_enrollment.update!(proofed_at: Time.zone.now) @@ -189,8 +189,8 @@ " Vérifiez votre e-mail pour votre résultat. Ce n'est pas vous?" \ " Signalez-le immédiatement: #{contact_number}. Réf: #{reference_string}", country_code: Phonelib.parse(phone_number).country, - ), - ) + ), + ) job.perform(passed_enrollment.id) end @@ -208,8 +208,8 @@ " Revise su correo electrónico para ver su resultado. ¿No fue usted?" \ " Informe ahora mismo: #{contact_number}. Ref: #{reference_string}", country_code: Phonelib.parse(phone_number).country, - ), - ) + ), + ) job.perform(passed_enrollment.id) end From a5b2244895fe5feeab3e6fb7c52e50cff89cf975 Mon Sep 17 00:00:00 2001 From: JackRyan1989 Date: Wed, 1 Nov 2023 16:36:21 -0400 Subject: [PATCH 09/10] Add enrollment code formatter and small edit to es translation --- app/jobs/in_person/send_proofing_notification_job.rb | 6 +++++- config/locales/telephony/es.yml | 2 +- .../jobs/in_person/send_proofing_notification_job_spec.rb | 8 +++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/jobs/in_person/send_proofing_notification_job.rb b/app/jobs/in_person/send_proofing_notification_job.rb index 3bd2d477d27..b5db32eadcf 100644 --- a/app/jobs/in_person/send_proofing_notification_job.rb +++ b/app/jobs/in_person/send_proofing_notification_job.rb @@ -53,6 +53,10 @@ def perform(enrollment_id) private + def formatter + Idv::InPerson::EnrollmentCodeFormatter + end + def log_job_completed(enrollment:) analytics(user: enrollment.user). idv_in_person_send_proofing_notification_job_completed( @@ -81,7 +85,7 @@ def notification_message(enrollment:) app_name: APP_NAME, proof_date: proof_date, contact_number: IdentityConfig.store.idv_contact_phone_number, - reference_string: enrollment.enrollment_code, + reference_string: formatter.format(enrollment.enrollment_code), ) end end diff --git a/config/locales/telephony/es.yml b/config/locales/telephony/es.yml index b6d1a123e06..14b60b64948 100644 --- a/config/locales/telephony/es.yml +++ b/config/locales/telephony/es.yml @@ -15,7 +15,7 @@ es: Este código expira en %{expiration} minutos. confirmation_ipp_enrollment_result: sms: |- - %{app_name}: Visitó la oficina de correos el %{proof_date}. Revise su correo electrónico para ver su resultado. ¿No fue usted? Informe ahora mismo: %{contact_number}. Ref: %{reference_string} + %{app_name}: Visitó la oficina de correos el %{proof_date}. Revise su correo electrónico. ¿No fue usted? Llame: %{contact_number}. Ref: %{reference_string} confirmation_otp: sms: |- %{app_name}: La contraseña es %{code}. Esta contraseña puede usarse una vez y se vence en %{expiration} minutos. No la comparta con nadie. diff --git a/spec/jobs/in_person/send_proofing_notification_job_spec.rb b/spec/jobs/in_person/send_proofing_notification_job_spec.rb index 7af5bcb2cbc..c283138d342 100644 --- a/spec/jobs/in_person/send_proofing_notification_job_spec.rb +++ b/spec/jobs/in_person/send_proofing_notification_job_spec.rb @@ -151,9 +151,11 @@ let(:phone_number) { passed_enrollment.notification_phone_configuration.formatted_phone } let(:contact_number) { '(844) 555-5555' } let(:reference_string) { passed_enrollment.enrollment_code } + let(:formatted_string) { '1234-5678-9012-3456' } before do allow(Telephony).to receive(:send_notification).and_return(sms_success_response) + allow(Idv::InPerson::EnrollmentCodeFormatter).to receive(:format).and_return(formatted_string) end it 'handles English language preference' do @@ -168,7 +170,7 @@ message: "Login.gov: You visited the Post Office on #{proofed_date}." \ " Check email for your result." \ " Not you? Report this right away: #{contact_number}." \ - " Ref: #{reference_string}", + " Ref: #{formatted_string}", country_code: Phonelib.parse(phone_number).country, ), ) @@ -187,7 +189,7 @@ to: phone_number, message: "Login.gov: Vous avez visité le bureau de poste le #{proofed_date}." \ " Vérifiez votre e-mail pour votre résultat. Ce n'est pas vous?" \ - " Signalez-le immédiatement: #{contact_number}. Réf: #{reference_string}", + " Signalez-le immédiatement: #{contact_number}. Réf: #{formatted_string}", country_code: Phonelib.parse(phone_number).country, ), ) @@ -206,7 +208,7 @@ to: phone_number, message: "Login.gov: Visitó la oficina de correos el #{proofed_date}." \ " Revise su correo electrónico para ver su resultado. ¿No fue usted?" \ - " Informe ahora mismo: #{contact_number}. Ref: #{reference_string}", + " Informe ahora mismo: #{contact_number}. Ref: #{formatted_string}", country_code: Phonelib.parse(phone_number).country, ), ) From fc7345ad8c432d72425dec207a25fb6401f5ee62 Mon Sep 17 00:00:00 2001 From: JackRyan1989 Date: Wed, 1 Nov 2023 17:02:25 -0400 Subject: [PATCH 10/10] Adding french translation and updating tests --- config/locales/telephony/fr.yml | 2 +- .../in_person/send_proofing_notification_job_spec.rb | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/config/locales/telephony/fr.yml b/config/locales/telephony/fr.yml index 5ddb9fec2f7..5e936074fd4 100644 --- a/config/locales/telephony/fr.yml +++ b/config/locales/telephony/fr.yml @@ -16,7 +16,7 @@ fr: minutes. confirmation_ipp_enrollment_result: sms: |- - %{app_name}: Vous avez visité le bureau de poste le %{proof_date}. Vérifiez votre e-mail pour votre résultat. Ce n'est pas vous? Signalez-le immédiatement: %{contact_number}. Réf: %{reference_string} + %{app_name}: Vous avez visité le bureau de poste le %{proof_date}. Vérifiez votre e-mail. Ce n'est pas vous? Signalez-le: %{contact_number}. Réf: %{reference_string} confirmation_otp: sms: |- %{app_name}: Votre code à usage unique est %{code}. Il est valable pendant %{expiration} minutes. Vous ne devez pas partager ce code avec personne. diff --git a/spec/jobs/in_person/send_proofing_notification_job_spec.rb b/spec/jobs/in_person/send_proofing_notification_job_spec.rb index c283138d342..66e04ea14fd 100644 --- a/spec/jobs/in_person/send_proofing_notification_job_spec.rb +++ b/spec/jobs/in_person/send_proofing_notification_job_spec.rb @@ -155,7 +155,8 @@ before do allow(Telephony).to receive(:send_notification).and_return(sms_success_response) - allow(Idv::InPerson::EnrollmentCodeFormatter).to receive(:format).and_return(formatted_string) + allow(Idv::InPerson::EnrollmentCodeFormatter).to receive(:format). + and_return(formatted_string) end it 'handles English language preference' do @@ -188,8 +189,8 @@ with( to: phone_number, message: "Login.gov: Vous avez visité le bureau de poste le #{proofed_date}." \ - " Vérifiez votre e-mail pour votre résultat. Ce n'est pas vous?" \ - " Signalez-le immédiatement: #{contact_number}. Réf: #{formatted_string}", + " Vérifiez votre e-mail. Ce n'est pas vous? Signalez-le: #{contact_number}." \ + " Réf: #{formatted_string}", country_code: Phonelib.parse(phone_number).country, ), ) @@ -207,8 +208,8 @@ with( to: phone_number, message: "Login.gov: Visitó la oficina de correos el #{proofed_date}." \ - " Revise su correo electrónico para ver su resultado. ¿No fue usted?" \ - " Informe ahora mismo: #{contact_number}. Ref: #{formatted_string}", + " Revise su correo electrónico. ¿No fue usted? Llame: #{contact_number}." \ + " Ref: #{formatted_string}", country_code: Phonelib.parse(phone_number).country, ), )