Class: InstagramConnect::Ingest::Handlers::MessagingReferral

Inherits:
Base
  • Object
show all
Defined in:
lib/instagram_connect/ingest/handlers/messaging_referral.rb

Overview

The customer arrived through an ig.me link, an ad, or a product tag. A referral opens the 24-hour messaging window even before they type anything, so it has to bump the thread's activity.

Only a standalone referral reaches here — one nested inside a message or postback stays with its parent event (see Registry).

Instance Attribute Summary

Attributes inherited from Base

#notification

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from InstagramConnect::Ingest::Handlers::Base

Class Method Details

.dedupe_key(event) ⇒ Object



11
12
13
14
15
# File 'lib/instagram_connect/ingest/handlers/messaging_referral.rb', line 11

def self.dedupe_key(event)
  ref = event.dig("referral", "ref").presence or return nil

  "#{event.dig('sender', 'id')}:#{ref}:#{event['timestamp']}"
end

Instance Method Details

#callObject



17
18
19
20
# File 'lib/instagram_connect/ingest/handlers/messaging_referral.rb', line 17

def call
  conversation.register_referral(ref: payload["ref"], at: referred_at)
  conversation
end