Class: ContactPointAddedHandler
- Inherits:
-
ApplicationJob
- Object
- ActiveJob::Base
- ApplicationJob
- ContactPointAddedHandler
- Includes:
- RailsEventStore::AsyncHandler
- Defined in:
- app/subscribers/contact_point_added_handler.rb
Overview
Handles Events::ContactPointAdded: when a new email contact point is created
for a party, re-evaluate that party's current product interests and buying group
against drip campaign criteria.
Campaign::AssignDripCampaigns deduplicates internally (skips if the drip
activity already exists for the party), so passing the current interests as
"just added" is safe — no duplicate activities will be created.
Runs asynchronously via ActiveJob so the expensive AssignDripCampaigns call
does not block the request cycle.
Instance Method Summary collapse
Instance Method Details
#perform(event) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/subscribers/contact_point_added_handler.rb', line 17 def perform(event) party = Party.find_by(id: event.data[:party_id]) return unless party customer = party.is_a?(Customer) ? party : party.try(:customer) return unless customer context = Campaign::DripContext.new( party:, product_line_ids_added: customer.product_line_ids, buying_group_id_added: customer. ) Campaign::AssignDripCampaigns.new.process(context) end |