Class: DeliveryAutomaticReleaseFailedNotificationHandler

Inherits:
ApplicationJob
  • Object
show all
Includes:
RailsEventStore::AsyncHandler
Defined in:
app/subscribers/delivery_automatic_release_failed_notification_handler.rb

Overview

Sends the "future-release auto-release failed (delivery is not at_warehouse)"
notification so the rep can investigate why the warehouse can't accept it.

WHY async via event: the delivery is captured by id at publish time and
re-queried at perform time, so a destroy between cron-publish and email-send
is a clean no-op instead of ActiveJob::DeserializationError
(AppSignal #4958). Replaces a direct InternalMailer.…deliver_later call
from Delivery.release_deliveries_past_release_date.

Instance Method Summary collapse

Instance Method Details

#perform(event) ⇒ void

This method returns an undefined value.

Processes a persisted auto-release-failed event: re-queries the delivery
and silently no-ops when it's gone.

Parameters:

  • event (RubyEventStore::Event)

    the persisted Events::DeliveryAutomaticReleaseFailed event

Raises:

  • (StandardError)

    if sending the notification fails



25
26
27
28
29
30
31
32
33
# File 'app/subscribers/delivery_automatic_release_failed_notification_handler.rb', line 25

def perform(event)
  delivery = Delivery.find_by(id: event.data[:delivery_id])
  return unless delivery

  DeliveryMailer.delivery_automatic_release_failed_notification(delivery).deliver_now
rescue StandardError => e
  ErrorReporting.error(e)
  raise
end