Class: InstagramConnect::Ingest
- Inherits:
-
Object
- Object
- InstagramConnect::Ingest
- Defined in:
- lib/instagram_connect/ingest.rb
Overview
Parses a verified Meta webhook payload and persists it into the engine's chat models, deduping on Meta's message id. After persistence it fires the configured host handlers (on_message / on_comment / on_postback) so the host can layer extras (notifications, AI replies) on top.
Returns a summary hash of what was processed.
Class Method Summary collapse
Instance Method Summary collapse
- #call(payload) ⇒ Object
-
#initialize(config) ⇒ Ingest
constructor
A new instance of Ingest.
Constructor Details
#initialize(config) ⇒ Ingest
Returns a new instance of Ingest.
13 14 15 |
# File 'lib/instagram_connect/ingest.rb', line 13 def initialize(config) @config = config end |
Class Method Details
.call(payload:, config: InstagramConnect.configuration) ⇒ Object
9 10 11 |
# File 'lib/instagram_connect/ingest.rb', line 9 def self.call(payload:, config: InstagramConnect.configuration) new(config).call(payload) end |
Instance Method Details
#call(payload) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/instagram_connect/ingest.rb', line 17 def call(payload) summary = { messages: 0, comments: 0, postbacks: 0, skipped: 0 } Array(payload && payload["entry"]).each do |entry| account = account_for(entry) if account.nil? summary[:skipped] += 1 next end Array(entry["messaging"]).each { |event| ingest_messaging(account, event, summary) } Array(entry["changes"]).each { |change| ingest_change(account, change, summary) } end summary end |