Class: InstagramConnect::Ingest::Handlers::Mentions
- Defined in:
- lib/instagram_connect/ingest/handlers/mentions.rb
Overview
Someone @mentioned the account, in a comment or in a caption.
Meta does not store these notifications and never re-delivers them, so this handler is the single point at which the event either becomes a row or ceases to exist. Nothing here is allowed to be best-effort.
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from InstagramConnect::Ingest::Handlers::Base
Class Method Details
.dedupe_key(event) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/instagram_connect/ingest/handlers/mentions.rb', line 10 def self.dedupe_key(event) value = event["value"] || {} media = value["media_id"].presence return nil if media.nil? "#{media}:#{value['comment_id'].presence || 'caption'}" end |
.requires_dedupe_key? ⇒ Boolean
18 19 20 |
# File 'lib/instagram_connect/ingest/handlers/mentions.rb', line 18 def self.requires_dedupe_key? true end |
Instance Method Details
#call ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/instagram_connect/ingest/handlers/mentions.rb', line 22 def call InstagramConnect::MediaItem.record(account: account, ig_media_id: value["media_id"]) InstagramConnect::Mention.record( account: account, kind: value["comment_id"].present? ? "comment" : "caption", ig_media_id: value["media_id"], comment_id: value["comment_id"], text: value["text"], from_username: value.dig("from", "username"), mentioned_at: mentioned_at ) end |