Class: DeliveryPrePackedNotificationHandler
- Inherits:
-
ApplicationJob
- Object
- ActiveJob::Base
- ApplicationJob
- DeliveryPrePackedNotificationHandler
- Includes:
- RailsEventStore::AsyncHandler
- Defined in:
- app/subscribers/delivery_pre_packed_notification_handler.rb
Overview
Sends the pre-packed-completion email to the team after a delivery
finishes pre-pack estimation.
WHY async via event: the delivery is captured by id at publish time and
re-queried at perform time, so a same-transaction destroy
(e.g. Itemizable#purge_empty_quoting_deliveries in set_totals) is a
clean no-op instead of ActiveJob::DeserializationError (AppSignal #4958).
Replaces a direct InternalMailer.…deliver_later call inside the
complete_picked flow that captured a GlobalID a destroy-in-same-tx
could invalidate before commit.
Instance Method Summary collapse
-
#perform(event) ⇒ void
Processes a persisted pre-pack completion event: clears the delivery's
suggested_packaging_textand emails the team.
Instance Method Details
#perform(event) ⇒ void
This method returns an undefined value.
Processes a persisted pre-pack completion event: clears the delivery's
suggested_packaging_text and emails the team.
28 29 30 31 32 33 34 35 36 37 |
# File 'app/subscribers/delivery_pre_packed_notification_handler.rb', line 28 def perform(event) delivery = Delivery.find_by(id: event.data[:delivery_id]) return unless delivery delivery.update_column(:suggested_packaging_text, nil) DeliveryMailer.delivery_pre_packed_notification(delivery).deliver_now rescue StandardError => e ErrorReporting.error(e) raise end |