Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions app/assets/stylesheets/email.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ h4 {
margin-bottom: 16px;
}

.mt-40 {
margin-top: 40px;
}

.button.large.expanded table a {
padding: 20px 0;
}
Expand Down
11 changes: 11 additions & 0 deletions app/jobs/get_usps_proofing_results_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def update_enrollment_status(enrollment, response)
when IPP_STATUS_FAILED
enrollment.update(status: :failed)
handle_failed_status(enrollment, response)
send_failed_email(enrollment.user, enrollment)
else
handle_unsupported_status(enrollment, response['status'])
end
Expand All @@ -166,4 +167,14 @@ def send_verified_email(user, enrollment)
).deliver_now_or_later
end
end

def send_failed_email(user, enrollment)
user.confirmed_email_addresses.each do |email_address|
UserMailer.in_person_failed(
user,
email_address,
enrollment: enrollment,
).deliver_now_or_later
end
end
end
12 changes: 11 additions & 1 deletion app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,24 @@ def in_person_ready_to_verify(user, email_address, first_name:, enrollment:)
def in_person_verified(user, email_address, enrollment:)
with_user_locale(user) do
@hide_title = true
@presenter = Idv::InPerson::VerifiedPresenter.new(enrollment: enrollment)
@presenter = Idv::InPerson::VerificationResultsEmailPresenter.new(enrollment: enrollment)
mail(
to: email_address.email,
subject: t('user_mailer.in_person_verified.subject', app_name: APP_NAME),
)
end
end

def in_person_failed(user, email_address, enrollment:)
with_user_locale(user) do
@presenter = Idv::InPerson::VerificationResultsEmailPresenter.new(enrollment: enrollment)
mail(
to: email_address.email,
subject: t('user_mailer.in_person_failed.subject', app_name: APP_NAME),
)
end
end

private

def email_should_receive_nonessential_notifications?(email)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Idv
module InPerson
class VerifiedPresenter
class VerificationResultsEmailPresenter
# update to user's time zone when out of pilot
USPS_SERVER_TIMEZONE = ActiveSupport::TimeZone['America/New_York']

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<div class="margin-top-5">
<table class="button expanded large radius">
<tbody>
<tr>
<td>
<table>
<tbody>
<tr>
<td style="text-align: center">
<%= link_to t('user_mailer.in_person_verified.sign_in'),
idv_url,
target: '_blank',
class: 'float-center',
rel: 'noopener' %>
</td>
</tr>
</tbody>
</table>
</td>
<td class="expander"></td>
</tr>
</tbody>
</table>
</div>

<p>
<%= link_to idv_url, idv_url, target: '_blank', rel: 'noopener' %>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to note, we're telling the user to follow these links to "try again", but unless the user is already signed in when they visit /verify, they would be presented with the sign in page, and we don't currently redirect the user to their original intended destination (LG-3737), so they would arrive at their account page after signing in.

</p>

<div class="s16">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separately we should consider changing the default font size for all emails, so we're not applying them to individual templates like this.

<br />
<%= t(
'user_mailer.in_person_verified.warning_contact_us_html',
contact_us_url: MarketingSite.contact_url,
sign_in_url: idv_url,
)
%>
</div>
20 changes: 20 additions & 0 deletions app/views/user_mailer/in_person_failed.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<div class="s16">
<%= t('user_mailer.in_person_verified.greeting') %><br>
<p class="s16">
<%= t(
'user_mailer.in_person_failed.intro',
location: @presenter.location_name,
date: @presenter.formatted_verified_date,
) %>
</p>
<p class="s16">
<%= t('user_mailer.in_person_failed.body', app_name: APP_NAME) %><br><br />
</p>
<strong><%= t('user_mailer.in_person_failed.verifying_identity') %></strong><br>
<ul class="usa-list">
<li><%= t('user_mailer.in_person_failed.verifying_step_not_expired') %></li>
<li><%= t('user_mailer.in_person_failed.verifying_step_proof_of_address') %></li>
</ul>
</div>

<%= render 'shared/in-person-verification-results-email-lower' %>
45 changes: 2 additions & 43 deletions app/views/user_mailer/in_person_verified.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,55 +6,14 @@
class: 'float-center padding-bottom-4',
) %>
<h4><%= message.subject %></h4>
<p>
<div class="s16">
<p class="s16">
<%= t('user_mailer.in_person_verified.greeting') %><br>
<%= t(
'user_mailer.in_person_verified.intro',
location: @presenter.location_name,
date: @presenter.formatted_verified_date,
) %><br /><br />
<%= t('user_mailer.in_person_verified.next_sign_in', app_name: APP_NAME) %>
</div>
</p>

<div class="mt-40">
<table class="button expanded large radius">
<tbody>
<tr>
<td>
<table>
<tbody>
<tr>
<td style="text-align: center">
<%= link_to t('user_mailer.in_person_verified.sign_in'),
idv_url,
target: '_blank',
class: 'float-center',
rel: 'noopener' %>
</td>
</tr>
</tbody>
</table>
</td>
<td class="expander"></td>
</tr>
</tbody>
</table>
</div>

<p>
<%= link_to idv_url, idv_url, target: '_blank', rel: 'noopener' %>
</p>

<p class="s16">
<br />
<%= t(
'user_mailer.in_person_verified.warning_contact_us_html',
contact_us_url: MarketingSite.contact_url,
sign_in_url: idv_url,
)
%>
<a>
</a>
</p>
<%= render 'shared/in-person-verification-results-email-lower' %>
14 changes: 14 additions & 0 deletions config/locales/user_mailer/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,20 @@ en:
%{app_name} %{help_link} or %{contact_link}.
subject: Email address deleted
help_link_text: Help Center
in_person_failed:
body: Click the button or copy the link below to try verifying your identity
online again through %{app_name}. If you are still experiencing issues,
please contact the agency you are trying to access.
intro: Your identity could not be verified at the %{location} Post Office on
%{date}.
subject: Your identity could not be verified in person
verifying_identity: 'When verifying your identity:'
verifying_step_not_expired: 'Your state-issued ID or driver’s license must not
be expired. We do not currently accept any other forms of
identification, such as passports and military IDs.'
verifying_step_proof_of_address: 'If you try to verify your identity in person
again, you need to bring a valid proof of address if your current
address is different than the address on your ID.'
in_person_ready_to_verify:
greeting: Hi %{name},
intro: Here are the details to verify your identity in person at a United States
Expand Down
15 changes: 15 additions & 0 deletions config/locales/user_mailer/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,21 @@ es:
%{app_name} %{help_link} o el %{contact_link}.
subject: Dirección de correo electrónico eliminada
help_link_text: Centro de Ayuda
in_person_failed:
body: Haga clic en el botón o copie el enlace siguiente para volver a intentar
verificar su identidad en línea con %{app_name}. Si sigue teniendo
problemas, póngase en contacto con la agencia a la que intenta acceder.
intro: El %{date}, no se pudo verificar su identidad en la oficina de correos de
%{location}.
subject: No se pudo verificar su identidad en persona
verifying_identity: 'Al verificar su identidad:'
verifying_step_not_expired: Su documento de identidad o permiso de conducir
emitido por el estado debe estar vigente. Por el momento, no aceptamos
otras formas de identificación, como pasaportes o cartillas militares.
verifying_step_proof_of_address: Si vuelve a intentar verificar su identidad en
persona, deberá llevar un comprobante de domicilio vigente si su
dirección actual es distinta de la que aparece en su documento de
identidad.
in_person_ready_to_verify:
greeting: 'Hola, %{name}:'
intro: Estos son los detalles para verificar su identidad en persona en una
Expand Down
17 changes: 17 additions & 0 deletions config/locales/user_mailer/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,23 @@ fr:
veuillez visiter le %{help_link} de %{app_name} ou %{contact_link}.
subject: Adresse email supprimée
help_link_text: Centre d’aide
in_person_failed:
body: Cliquez sur le bouton ou copiez le lien ci-dessous pour essayer de
vérifier à nouveau votre identité en ligne par le biais de %{app_name}.
Si vous rencontrez toujours des problèmes, veuillez contacter l’agence à
laquelle vous essayez d’accéder.
intro: Votre identité n’a pas pu être vérifiée au bureau de poste de %{location}
le %{date}.
subject: Votre identité n’a pas pu être vérifiée en personne
verifying_identity: 'Lors de la vérification de votre identité :'
verifying_step_not_expired: Votre carte d’identité ou votre permis de conduire
délivré par l’État ne doit pas être périmé. Nous n’acceptons
actuellement aucune autre forme d’identification, comme les passeports
et les cartes d’identité militaires.
verifying_step_proof_of_address: Si vous tentez à nouveau de vérifier votre
identité en personne, vous devez apporter un justificatif de domicile
valable si votre adresse actuelle est différente de celle figurant sur
votre pièce d’identité.
in_person_ready_to_verify:
greeting: Bonjour %{name},
intro: Voici les détails pour vérifier votre identité en personne dans un bureau
Expand Down
26 changes: 24 additions & 2 deletions spec/jobs/get_usps_proofing_results_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
)
end

it 'logs details about failed requests' do
it 'logs details about a failed proofing' do
stub_request_token
stub_request_failed_proofing_results

Expand Down Expand Up @@ -141,7 +141,29 @@
)
end

it 'updates enrollment records and activates profiles on 2xx responses with valid JSON' do
it 'sends proofing failed email on response with failed status' do
stub_request_token
stub_request_failed_proofing_results

allow(InPersonEnrollment).to receive(:needs_usps_status_check).
and_return([pending_enrollment])

mailer = instance_double(ActionMailer::MessageDelivery, deliver_now_or_later: true)
user = pending_enrollment.user
user.email_addresses.each do |email_address|
expect(UserMailer).to receive(:in_person_failed).
with(
user,
email_address,
enrollment: instance_of(InPersonEnrollment),
).
and_return(mailer)
end

job.perform(Time.zone.now)
end

it 'updates enrollment records and activates profiles on response with passed status' do
stub_request_token
stub_request_passed_proofing_results

Expand Down
8 changes: 8 additions & 0 deletions spec/mailers/previews/user_mailer_preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ def in_person_verified
)
end

def in_person_failed
UserMailer.in_person_failed(
user,
email_address_record,
enrollment: in_person_enrollment,
)
end

private

def user
Expand Down
21 changes: 21 additions & 0 deletions spec/mailers/user_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,27 @@ def expect_email_body_to_have_help_and_contact_links
it_behaves_like 'an email that respects user email locale preference'
end

describe '#in_person_failed' do
let(:enrollment) {
create(
:in_person_enrollment,
selected_location_details: { name: 'FRIENDSHIP' },
status_updated_at: Time.zone.now - 2.hours,
)
}

let(:mail) do
UserMailer.in_person_failed(
user,
user.email_addresses.first,
enrollment: enrollment,
)
end

it_behaves_like 'a system email'
it_behaves_like 'an email that respects user email locale preference'
end

def strip_tags(str)
ActionController::Base.helpers.strip_tags(str)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.describe Idv::InPerson::VerifiedPresenter do
RSpec.describe Idv::InPerson::VerificationResultsEmailPresenter do
let(:location_name) { 'FRIENDSHIP' }
let(:status_updated_at) { described_class::USPS_SERVER_TIMEZONE.parse('2022-07-14T00:00:00Z') }
let!(:enrollment) do
Expand Down