instagram_connect 0.3.3 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 610d72aa6d017bd24db1f7b670ae377a9d6375c74195f21d2992a4249daadc91
4
- data.tar.gz: 453de0f0a35ee225997a54292260e2b40dcf302b32242fe05f108ef3a702917c
3
+ metadata.gz: 6d411544448610a0b11fa1efc08960a9999008117c8a17f8119311f45ae55764
4
+ data.tar.gz: bb5c2ec09be740aa03358058b64468fa9e415d7046b003fdd065da499d8488cf
5
5
  SHA512:
6
- metadata.gz: 833aa49017299e66d1b2b6470ed32299ade4863cd8fd3393aa2790231af47e98c1e33412c200f6e7f5eec319d842b6cf4d5a27951cdf137223731caaa5ae435e
7
- data.tar.gz: 62bf43bce6b59381057c3e26b0b201f529cac269eaadaf5497a61f5217d60858f8b2d6c223912aa0703fec3d415c011ba8a8bf4ac6edfd60fdb5927da3fa055e
6
+ metadata.gz: 02257cd24bb80798df5cc576ac7ccf62dc9efcdde4458b1697bc48e4971bea86927d471e46739ca858c48e3a7c69926ed64518dea62b27ccaa097bc9ccc0f61c
7
+ data.tar.gz: d617a13ad8229ce7a3d53f46a8aadba6974ce06de7f81e8fe462cb69d3e550d4bc87f71ec793abf89fd97163c4f37a0348ec0ac07da9a1549190bd9874a46ee0
data/CHANGELOG.md CHANGED
@@ -6,6 +6,28 @@ All notable changes to this project are documented here. The format follows
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.3.4] - 2026-07-26
10
+
11
+ ### Fixed
12
+
13
+ - **The Page was never subscribed, so Meta delivered nothing at all.**
14
+ `POST /{page-id}/subscribed_apps` takes Meta's **Page** field vocabulary; the gem sent the
15
+ **Instagram** object's names. Meta rejects the entire call — every field, not just the offender —
16
+ on the first name it does not recognise:
17
+
18
+ (#100) Param subscribed_fields[4] must be one of {...} - got "messaging_seen"
19
+
20
+ So a correctly configured, published app with a valid Page token received zero webhooks. The two
21
+ lists are now deliberately separate: `subscribed_fields` is what ingest can parse, and
22
+ `page_subscribed_fields` translates it to Page names (`messaging_seen` → `message_reads`,
23
+ `messaging_referral` → `messaging_referrals`, `messaging_handover` → `messaging_handovers`) and
24
+ drops the four that exist only on the `instagram` object and are subscribed in the app dashboard
25
+ instead (`comments`, `live_comments`, `mentions`, `story_insights`).
26
+ - **Conversation sync was rejected for asking too much.** Meta answered a 50-per-page conversations
27
+ walk with "Please reduce the amount of data you're asking for". The default page size is now 20;
28
+ the cursor walk makes a smaller page cost one extra round trip and nothing else.
29
+
30
+
9
31
  ## [0.3.3] - 2026-07-26
10
32
 
11
33
  ### Fixed
@@ -28,10 +28,19 @@ module InstagramConnect
28
28
 
29
29
  HTTP_TIMEOUT = 15
30
30
 
31
+ # What we ask Meta to deliver to the webhook endpoint.
31
32
  def self.subscribed_fields
32
33
  Ingest::Registry.subscribable_fields
33
34
  end
34
35
 
36
+ # What `subscribed_apps` will actually accept — the Page object names, minus
37
+ # the fields that only exist on the `instagram` object. Sending an Instagram
38
+ # name here fails the ENTIRE call, so the two lists are deliberately
39
+ # separate rather than one list used twice.
40
+ def self.page_subscribed_fields
41
+ Ingest::Registry.page_subscribable_fields
42
+ end
43
+
35
44
  # Cheap negative check so an install with no connected account never
36
45
  # enqueues anything.
37
46
  def self.enqueue_if_needed
@@ -105,7 +114,7 @@ module InstagramConnect
105
114
  def ensure_subscription(account)
106
115
  return if account.page_access_token.blank?
107
116
 
108
- wanted = self.class.subscribed_fields
117
+ wanted = self.class.page_subscribed_fields
109
118
  current = graph_get(account, "/#{account.page_id}/subscribed_apps", fields: "subscribed_fields")
110
119
  subscribed = Array(current["data"]).flat_map { |app| Array(app["subscribed_fields"]) }.map(&:to_s)
111
120
 
@@ -166,7 +166,11 @@ module InstagramConnect
166
166
  # Facebook-Login path that is the PAGE, not the Instagram user — verified
167
167
  # in production, where the Instagram user id answered with a capability
168
168
  # error while holding a perfectly good Page token.
169
- def list_conversations(node_id: @ig_user_id, limit: 50)
169
+ # limit defaults low deliberately. Meta rejected 50 outright on a live
170
+ # account with "Please reduce the amount of data you're asking for" — the
171
+ # conversations edge is expensive per row, and the cursor walk means a
172
+ # smaller page costs nothing but an extra round trip.
173
+ def list_conversations(node_id: @ig_user_id, limit: 20)
170
174
  collect("/#{require_ig_user_id(node_id)}/conversations",
171
175
  { platform: "instagram", fields: "id,updated_time", limit: limit })
172
176
  end
@@ -43,6 +43,33 @@ module InstagramConnect
43
43
  story_insights
44
44
  ].freeze
45
45
 
46
+ # Meta's Page object and Instagram object use DIFFERENT names for the same
47
+ # webhook. `POST /{page-id}/subscribed_apps` takes the PAGE vocabulary and
48
+ # rejects the whole call — every field, not just the offender — on the
49
+ # first name it does not recognise:
50
+ #
51
+ # (#100) Param subscribed_fields[4] must be one of {...} - got "messaging_seen"
52
+ #
53
+ # That one rejection is why a correctly configured Page received nothing at
54
+ # all. Fields with no Page equivalent (comments, mentions, story_insights)
55
+ # are subscribed on the `instagram` object in the app dashboard instead,
56
+ # and must not be sent here.
57
+ PAGE_FIELD_NAMES = {
58
+ "messaging_seen" => "message_reads",
59
+ "messaging_referral" => "messaging_referrals",
60
+ "messaging_handover" => "messaging_handovers"
61
+ }.freeze
62
+
63
+ INSTAGRAM_ONLY_FIELDS = %w[comments live_comments mentions story_insights].freeze
64
+
65
+ # The subset of KNOWN_FIELDS that `subscribed_apps` accepts, translated to
66
+ # the names Meta uses on a Page.
67
+ def self.page_subscribable_fields
68
+ (KNOWN_FIELDS - INSTAGRAM_ONLY_FIELDS)
69
+ .map { |field| PAGE_FIELD_NAMES.fetch(field, field) }
70
+ .uniq
71
+ end
72
+
46
73
  # Shape tests in priority order. `is_echo` must be checked before the
47
74
  # plain `message` case, since an echo carries a message too.
48
75
  MESSAGING_SHAPES = [
@@ -1,3 +1,3 @@
1
1
  module InstagramConnect
2
- VERSION = "0.3.3"
2
+ VERSION = "0.3.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: instagram_connect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kshitiz Sinha