Class: EVSS::DisabilityCompensationForm::Form526DocumentUploadFailureEmail

Inherits:
Job
  • Object
show all
Defined in:
app/sidekiq/evss/disability_compensation_form/form526_document_upload_failure_email.rb

Constant Summary collapse

STATSD_METRIC_PREFIX =
'api.form_526.veteran_notifications.document_upload_failure_email'
ZSF_DD_TAG_FUNCTION =
'526_evidence_upload_failure_email_queuing'

Constants included from Sidekiq::Form526JobStatusTracker::JobTracker

Sidekiq::Form526JobStatusTracker::JobTracker::STATSD_KEY_PREFIX

Instance Method Summary collapse

Methods inherited from Job

#submission

Methods included from Sidekiq::Form526JobStatusTracker::JobTracker

#error_message, #job_success, #job_try, #klass, #log_error, #log_info, #metrics, #non_retryable_error_handler, #update_background_job_errors, #upsert_job_status, #with_tracking

Methods included from Sidekiq::Form526JobStatusTracker::BackupSubmission

#send_backup_submission_if_enabled

Methods included from SentryLogging

#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger, #set_sentry_metadata

Instance Method Details

#log_mailer_dispatch(log_info, submission, email_response = {}) ⇒ Object (private)

[View source] [View on GitHub]

114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'app/sidekiq/evss/disability_compensation_form/form526_document_upload_failure_email.rb', line 114

def log_mailer_dispatch(log_info, submission, email_response = {})
  StatsD.increment("#{STATSD_METRIC_PREFIX}.success")

  Rails.logger.info('Form526DocumentUploadFailureEmail notification dispatched', log_info)

  cl = caller_locations.first
  call_location = Logging::CallLocation.new(ZSF_DD_TAG_FUNCTION, cl.path, cl.lineno)
  zsf_monitor = ZeroSilentFailures::Monitor.new(Form526Submission::ZSF_DD_TAG_SERVICE)

  zsf_monitor.log_silent_failure_avoided(
    log_info.merge(email_confirmation_id: email_response&.id),
    submission.,
    call_location:
  )
end

#perform(form526_submission_id, supporting_evidence_attachment_guid) ⇒ Object

[View source] [View on GitHub]

75
76
77
78
79
80
81
82
83
84
85
# File 'app/sidekiq/evss/disability_compensation_form/form526_document_upload_failure_email.rb', line 75

def perform(form526_submission_id, supporting_evidence_attachment_guid)
  super(form526_submission_id)

  submission = Form526Submission.find(form526_submission_id)

  with_tracking('Form526DocumentUploadFailureEmail', submission.saved_claim_id, form526_submission_id) do
    send_notification_mailer(submission, supporting_evidence_attachment_guid)
  end
rescue => e
  retryable_error_handler(e)
end

#retryable_error_handler(error) ⇒ Object (private)

[View source] [View on GitHub]

130
131
132
133
# File 'app/sidekiq/evss/disability_compensation_form/form526_document_upload_failure_email.rb', line 130

def retryable_error_handler(error)
  super(error)
  raise error
end

#send_notification_mailer(submission, supporting_evidence_attachment_guid) ⇒ Object (private)

[View source] [View on GitHub]

89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'app/sidekiq/evss/disability_compensation_form/form526_document_upload_failure_email.rb', line 89

def send_notification_mailer(submission, supporting_evidence_attachment_guid)
  form_attachment = SupportingEvidenceAttachment.find_by!(guid: supporting_evidence_attachment_guid)

  # We need to obscure the original filename as it may contain PII
  obscured_filename = form_attachment.obscured_filename
  email_address = submission.veteran_email_address
  first_name = submission.get_first_name
   = submission.format_creation_time_for_mailers

  notify_service_bd = Settings.vanotify.services.benefits_disability
  notify_client = VaNotify::Service.new(notify_service_bd.api_key)
  template_id = notify_service_bd.template_id.form526_document_upload_failure_notification_template_id

  notify_response = notify_client.send_email(
    email_address:,
    template_id:,
    personalisation: { first_name:, filename: obscured_filename, date_submitted: }
  )

  log_info = { obscured_filename:, form526_submission_id: submission.id,
               supporting_evidence_attachment_guid:, timestamp: Time.now.utc }

  log_mailer_dispatch(log_info, submission, notify_response)
end