Skip to content

Commit

Permalink
wrap all pinwheel_account accesses in a check for its presence (#385)
Browse files Browse the repository at this point in the history
Co-authored-by: allthesignals <[email protected]>
  • Loading branch information
millerti and allthesignals authored Jan 22, 2025
1 parent 64654c5 commit 0f245f0
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions app/app/controllers/webhooks/pinwheel/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,23 @@ def create

if PinwheelAccount::EVENTS_MAP.keys.include?(params["event"])
pinwheel_account = PinwheelAccount.find_by_pinwheel_account_id(params["payload"]["account_id"])
pinwheel_account.update!(PinwheelAccount::EVENTS_MAP[params["event"]] => Time.now) if pinwheel_account.present?

if params.dig("payload", "outcome") == "error" || params.dig("payload", "outcome") == "pending"
pinwheel_account.update!(PinwheelAccount::EVENTS_ERRORS_MAP[params["event"]] => Time.now) if pinwheel_account.present?
end
if pinwheel_account.present?
pinwheel_account.update!(PinwheelAccount::EVENTS_MAP[params["event"]] => Time.now)

if params.dig("payload", "outcome") == "error" || params.dig("payload", "outcome") == "pending"
pinwheel_account.update!(PinwheelAccount::EVENTS_ERRORS_MAP[params["event"]] => Time.now)
end

if pinwheel_account.has_fully_synced?
track_account_synced_event(@cbv_flow, pinwheel_account)
if pinwheel_account.has_fully_synced?
track_account_synced_event(@cbv_flow, pinwheel_account)

PaystubsChannel.broadcast_to(@cbv_flow, {
event: "cbv.status_update",
account_id: params["payload"]["account_id"],
has_fully_synced: true
})
PaystubsChannel.broadcast_to(@cbv_flow, {
event: "cbv.status_update",
account_id: params["payload"]["account_id"],
has_fully_synced: true
})
end
end
end
end
Expand Down

0 comments on commit 0f245f0

Please sign in to comment.