instagram_connect 0.3.17 → 0.3.18

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: 1e14ef34f00e794b30aa2426b8c98c2b8dda7546c8b8c9ef86703b22a7ecbed4
4
- data.tar.gz: 0a8ef8889d73b990c0cb643c23ac285b3758a7b56526fed12039f6d9fb25c501
3
+ metadata.gz: 1a7dcce7b2dae41f81ed1e5d6f03a34a629c6e5ae90125bb673cb47eaea098f1
4
+ data.tar.gz: 8941b7ec8f788b2cd8e007282ba06d1a1480d2ed89bf2fd4f177e56aed384b1b
5
5
  SHA512:
6
- metadata.gz: f90f4345d58617e5a70ff2f138f4151e73d7bc09976537e9c0e9553aa16b6b0443ca4330534712e7b048f214e5c4104d422fe4efcf2aa03380730e6c39998348
7
- data.tar.gz: 17fc37a2ae066b15f0d3978e3483d4b5c69bd91203c8d8c07ec09e03bd0836b788e55cc706c6bd6958912d58902042a6975e760f78d6bc1c02f59a544d1ec2cc
6
+ metadata.gz: 779d9af0a92b505f7a93ca0b6502b8c82e6a4286782da41ddeb26f698a227e8107b56458d6a9a13bd504ff4d625a2a5414d062dfbec15f6b8eaeb33aeec794f3
7
+ data.tar.gz: 846973e8a0ed72106f650fa4342d493c15c4f5e4d79b87155c32a84e7545d96487403d5659d0587be3a4c7de2068089eb59afb3c8c003ac787746f8eac787c7a
data/CHANGELOG.md CHANGED
@@ -6,6 +6,23 @@ All notable changes to this project are documented here. The format follows
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.3.18] - 2026-07-28
10
+
11
+ ### Added
12
+
13
+ - **The comment-triggered DM (private reply) can carry quick replies.** It rides the full
14
+ messaging endpoint, so a funnel can open with buttons — titles clipped to Meta's 20 characters.
15
+
16
+ ### Fixed
17
+
18
+ - **Comment webhooks no longer arrive stamped January 1970.** Meta sends messaging-webhook
19
+ timestamps in MILLISECONDS but comment/mention change webhooks in SECONDS; dividing everything
20
+ by 1000 collapsed every comment's clock to the epoch — which downstream read as "older than
21
+ Meta's 7-day reply window" and silently skipped every realtime comment automation.
22
+ `Envelope.time_from` now decides the unit by magnitude, so no caller has to know which field a
23
+ value came from.
24
+
25
+
9
26
  ## [0.3.17] - 2026-07-28
10
27
 
11
28
  ### Added
@@ -89,8 +89,19 @@ module InstagramConnect
89
89
  end
90
90
 
91
91
  # One-time private reply to a comment (comment -> DM), valid 7 days.
92
- def private_reply(comment_id:, text:)
93
- post("/me/messages", { recipient: { comment_id: comment_id }, message: { text: text } })
92
+ # The one DM a comment entitles us to send. It rides the full messaging
93
+ # endpoint (recipient by comment_id), so it can carry quick replies
94
+ # which is how a comment-triggered funnel opens with buttons.
95
+ def private_reply(comment_id:, text:, quick_replies: nil)
96
+ message = { text: text }
97
+ if quick_replies.present?
98
+ message[:quick_replies] = Array(quick_replies).map do |reply|
99
+ { content_type: "text",
100
+ title: reply[:title].to_s[0, 20],
101
+ payload: reply[:payload].to_s }
102
+ end
103
+ end
104
+ post("/me/messages", { recipient: { comment_id: comment_id }, message: message })
94
105
  end
95
106
 
96
107
  # --- Comments --------------------------------------------------------
@@ -11,13 +11,23 @@ module InstagramConnect
11
11
  # storing it would corrupt every ordering that reads occurred_at.
12
12
  MAX_SECONDS = 4_102_444_800 # 2100-01-01
13
13
 
14
- # Meta timestamps are milliseconds since the epoch. Ordering off this
15
- # rather than our own created_at is what stops a delayed webhook batch
16
- # silently reordering a conversation.
17
- def self.time_from(millis)
18
- return nil if millis.nil?
14
+ # Below this, a value can only be SECONDS since the epoch: the smallest
15
+ # millisecond timestamp Meta could send (year 2001+) is ~10^12, and a
16
+ # second-count will not reach 10^11 until the year 5138.
17
+ MILLIS_FLOOR = 100_000_000_000
19
18
 
20
- seconds = millis.to_i / 1000.0
19
+ # Meta is inconsistent on the wire: messaging webhooks stamp in
20
+ # MILLISECONDS, comment/mention change webhooks stamp entry.time in
21
+ # SECONDS. Dividing everything by 1000 turned every comment webhook's
22
+ # clock into January 1970 — which read as "older than Meta's 7-day
23
+ # reply window" and silently skipped every realtime comment automation.
24
+ # The magnitude decides the unit; no caller has to know which field it
25
+ # came from.
26
+ def self.time_from(value)
27
+ return nil if value.nil?
28
+
29
+ number = value.to_i
30
+ seconds = number >= MILLIS_FLOOR ? number / 1000.0 : number.to_f
21
31
  return nil unless seconds.finite? && seconds >= 0 && seconds <= MAX_SECONDS
22
32
 
23
33
  Time.at(seconds).utc
@@ -1,5 +1,9 @@
1
1
  require "json"
2
2
 
3
+ # blank?/present? on plain objects — this file must not depend on which
4
+ # spec or host loaded ActiveSupport core extensions first.
5
+ require "active_support/core_ext/object/blank"
6
+
3
7
  module InstagramConnect
4
8
  # Meta's own account of how much of the rate budget a call just consumed,
5
9
  # parsed from the response headers.
@@ -1,3 +1,3 @@
1
1
  module InstagramConnect
2
- VERSION = "0.3.17"
2
+ VERSION = "0.3.18"
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.17
4
+ version: 0.3.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kshitiz Sinha