instagram_connect 0.3.16 → 0.3.17

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: f8254fa918cab3d7ebaba751290cbcccb3ae3b00a3cedfba63e453e3c2215d6b
4
- data.tar.gz: 5c9c4e6b6e081601028d96cf0607eab8c968544563244c1b30179348ecc68469
3
+ metadata.gz: 1e14ef34f00e794b30aa2426b8c98c2b8dda7546c8b8c9ef86703b22a7ecbed4
4
+ data.tar.gz: 0a8ef8889d73b990c0cb643c23ac285b3758a7b56526fed12039f6d9fb25c501
5
5
  SHA512:
6
- metadata.gz: 7f63bf53d0569e50ee76bda51230f8a2432045c8a5aff8ac4ed75f7d9f64c919ab45d82b0b37226f738a363202800f49cf84b47ac4031c51863028773a86d5a2
7
- data.tar.gz: d5ab0a07d616411f4013dfdcb067fe8d61894eb132f2a5e2d9e5b726057ec7132429650f073070b603ea2412d751c1d424fc6b4e646d104f2f5437e72e0ba173
6
+ metadata.gz: f90f4345d58617e5a70ff2f138f4151e73d7bc09976537e9c0e9553aa16b6b0443ca4330534712e7b048f214e5c4104d422fe4efcf2aa03380730e6c39998348
7
+ data.tar.gz: 17fc37a2ae066b15f0d3978e3483d4b5c69bd91203c8d8c07ec09e03bd0836b788e55cc706c6bd6958912d58902042a6975e760f78d6bc1c02f59a544d1ec2cc
data/CHANGELOG.md CHANGED
@@ -6,6 +6,18 @@ All notable changes to this project are documented here. The format follows
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.3.17] - 2026-07-28
10
+
11
+ ### Added
12
+
13
+ - **The comment sweep announces fresh imports.** A comment younger than 24 hours that arrives via
14
+ `SyncCommentsJob` rather than its webhook now fires the host's `on_comment` callback — once, on
15
+ first import only, never for enriched webhook rows or older history. A fresh comment whose
16
+ webhook was lost (or that raced an automation rule being created) is fully actionable for 7 days
17
+ under Meta's private-reply window, so automations now self-heal on the next sweep instead of
18
+ silently never firing. A host callback that raises is logged and never kills the walk.
19
+
20
+
9
21
  ## [0.3.16] - 2026-07-28
10
22
 
11
23
  ### Fixed
@@ -72,6 +72,13 @@ module InstagramConnect
72
72
  end
73
73
  end
74
74
 
75
+ # A sweep-imported comment younger than this still deserves the host's
76
+ # on_comment automations: Meta's private-reply window is 7 days, so a
77
+ # fresh comment whose webhook was lost (or raced a rule being created)
78
+ # is fully actionable when the next sweep finds it. Older imports are
79
+ # history and stay silent — nobody wants a DM about last month.
80
+ FRESH_WINDOW = 24.hours
81
+
75
82
  def upsert(account, ig_media_id, item)
76
83
  comment = Comment.record(
77
84
  account: account,
@@ -81,12 +88,28 @@ module InstagramConnect
81
88
  from_username: item["username"] || item.dig("from", "username"),
82
89
  parent_id: item["parent_id"].presence
83
90
  )
91
+ freshly_created = comment.previously_new_record?
84
92
  comment.update!(
85
93
  from_ig_id: item.dig("from", "id") || comment.from_ig_id,
86
94
  commented_at: parse_time(item["timestamp"]) || comment.commented_at,
87
95
  like_count: item["like_count"],
88
96
  hidden_at: item["hidden"] ? (comment.hidden_at || Time.current) : nil
89
97
  )
98
+ announce(comment) if freshly_created
99
+ comment
100
+ end
101
+
102
+ # Only NEWLY imported, still-fresh comments — a webhook-created row being
103
+ # enriched here already had its turn, and host automation jobs are
104
+ # idempotent per comment anyway. A host callback must never kill the walk.
105
+ def announce(comment)
106
+ return if comment.commented_at.blank? || comment.commented_at < FRESH_WINDOW.ago
107
+
108
+ callback = InstagramConnect.configuration.on_comment
109
+ callback&.call(comment)
110
+ rescue StandardError => e
111
+ logger.error("[instagram_connect] on_comment callback failed for " \
112
+ "comment=#{comment.comment_id}: #{e.class}: #{e.message}")
90
113
  end
91
114
 
92
115
  def parse_time(value)
@@ -1,3 +1,3 @@
1
1
  module InstagramConnect
2
- VERSION = "0.3.16"
2
+ VERSION = "0.3.17"
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.16
4
+ version: 0.3.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kshitiz Sinha