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
19 changes: 15 additions & 4 deletions app/controllers/idv/by_mail/request_letter_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,11 @@ def update_tracking
resend: resend_requested?,
first_letter_requested_at: first_letter_requested_at,
hours_since_first_letter:
gpo_mail_service.hours_since_first_letter(first_letter_requested_at),
phone_step_attempts: gpo_mail_service.phone_step_attempts,
hours_since_first_letter(first_letter_requested_at),
phone_step_attempts: RateLimiter.new(
user: current_user,
rate_limit_type: :proof_address,
).attempts,
**ab_test_analytics_buckets,
)
create_user_event(:gpo_mail_sent, current_user)
Expand All @@ -87,6 +90,11 @@ def first_letter_requested_at
current_user.gpo_verification_pending_profile&.gpo_verification_pending_at
end

def hours_since_first_letter(first_letter_requested_at)
first_letter_requested_at ?
(Time.zone.now - first_letter_requested_at).to_i.seconds.in_hours.to_i : 0
end

def confirm_mail_not_rate_limited
redirect_to idv_enter_password_url if gpo_mail_service.rate_limited?
end
Expand All @@ -97,8 +105,11 @@ def resend_letter
resend: true,
first_letter_requested_at: first_letter_requested_at,
hours_since_first_letter:
gpo_mail_service.hours_since_first_letter(first_letter_requested_at),
phone_step_attempts: gpo_mail_service.phone_step_attempts,
hours_since_first_letter(first_letter_requested_at),
phone_step_attempts: RateLimiter.new(
user: current_user,
rate_limit_type: :proof_address,
).attempts,
**ab_test_analytics_buckets,
)
confirmation_maker = confirmation_maker_perform
Expand Down
17 changes: 10 additions & 7 deletions app/controllers/idv/enter_password_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,6 @@ def confirm_current_password
redirect_to idv_enter_password_url
end

def gpo_mail_service
@gpo_mail_service ||= Idv::GpoMail.new(current_user)
end

def init_profile
idv_session.create_profile_from_applicant_with_password(
password,
Expand All @@ -133,10 +129,12 @@ def init_profile
analytics.idv_gpo_address_letter_enqueued(
enqueued_at: Time.zone.now,
resend: false,
phone_step_attempts: gpo_mail_service.phone_step_attempts,
phone_step_attempts: RateLimiter.new(
user: current_user,
rate_limit_type: :proof_address,
).attempts,
first_letter_requested_at: first_letter_requested_at,
hours_since_first_letter:
gpo_mail_service.hours_since_first_letter(first_letter_requested_at),
hours_since_first_letter: hours_since_first_letter(first_letter_requested_at),
**ab_test_analytics_buckets,
)
end
Expand All @@ -155,6 +153,11 @@ def first_letter_requested_at
idv_session.profile.gpo_verification_pending_at
end

def hours_since_first_letter(first_letter_requested_at)
first_letter_requested_at ?
(Time.zone.now - first_letter_requested_at).to_i.seconds.in_hours.to_i : 0
end

def valid_password?
current_user.valid_password?(password)
end
Expand Down
11 changes: 0 additions & 11 deletions app/services/idv/gpo_mail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,6 @@ def profile_too_old?
current_user.pending_profile.created_at < min_creation_date
end

# Next two methods are analytics helpers used from RequestLetterController and
# EnterPasswordController
def phone_step_attempts
RateLimiter.new(user: @current_user, rate_limit_type: :proof_address).attempts
end

def hours_since_first_letter(first_letter_requested_at)
first_letter_requested_at ?
(Time.zone.now - first_letter_requested_at).to_i.seconds.in_hours.to_i : 0
end

private

def window_limit_enabled?
Expand Down