Class: DeliveryPrePackCancelledNotificationHandler
- Inherits:
-
ApplicationJob
- Object
- ActiveJob::Base
- ApplicationJob
- DeliveryPrePackCancelledNotificationHandler
- Includes:
- RailsEventStore::AsyncHandler
- Defined in:
- app/subscribers/delivery_pre_pack_cancelled_notification_handler.rb
Overview
Sends the pre-pack-cancellation email to the warehouse / requester after
an in-progress pre-pack is aborted.
WHY async via event: the delivery is captured by id at publish time and
re-queried at perform time, so a same-transaction destroy (the
Itemizable purge_empty_quoting_deliveries zombie cleanup) is a clean
no-op instead of ActiveJob::DeserializationError (AppSignal #4958).
Replaces a direct InternalMailer.…deliver_later call whose GlobalID
arg could be invalidated by a destroy in the same transaction before
the after-commit enqueue actually pushed to Redis.
Instance Method Summary collapse
-
#perform(event) ⇒ void
Processes a persisted pre-pack cancellation event: clears the delivery's
suggested_packaging_text, resolves the cancelling Party (if its id still references a live row), and emails the warehouse / requester.
Instance Method Details
#perform(event) ⇒ void
This method returns an undefined value.
Processes a persisted pre-pack cancellation event: clears the delivery's
suggested_packaging_text, resolves the cancelling Party (if its id still
references a live row), and emails the warehouse / requester.
30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/subscribers/delivery_pre_pack_cancelled_notification_handler.rb', line 30 def perform(event) delivery = Delivery.find_by(id: event.data[:delivery_id]) return unless delivery delivery.update_column(:suggested_packaging_text, nil) cancelled_by = Party.find_by(id: event.data[:cancelled_by_id]) DeliveryMailer.delivery_pre_pack_cancelled_notification(delivery, cancelled_by: cancelled_by).deliver_now rescue StandardError => e ErrorReporting.error(e) raise end |