Class: OpenLoam::InboundWebhookDelivery

Inherits:
TenantRecord
  • Object
show all
Defined in:
app/models/open_loam/inbound_webhook_delivery.rb

Overview

One received inbound webhook. Two jobs: an idempotency ledger (a unique (source_id, external_id) index turns a replayed delivery into a no-op) and an audit/payload store — the raw body is kept here so an event subscriber reads it, keeping the published event payload scalar-clean (ids only).

Instance Method Summary collapse

Instance Method Details

#payload_hash ⇒ Object

(source_id, external_id) uniqueness is enforced by a DB index — the ledger must be race-safe, so we rely on the constraint, not a validation.



15
16
17
18
19
20
21
22
# File 'app/models/open_loam/inbound_webhook_delivery.rb', line 15

def payload_hash
  value = self[:payload]
  return value if value.is_a?(Hash)

  JSON.parse(value.to_s.presence || "{}")
rescue JSON::ParserError
  {}
end