instagram_connect 0.3.10 → 0.3.11
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 +4 -4
- data/CHANGELOG.md +14 -0
- data/app/jobs/instagram_connect/sync_comments_job.rb +31 -7
- data/lib/instagram_connect/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 34e72217b3285a05cf86874ad6d225bc92304f0f496381b86707b257d6e25571
|
|
4
|
+
data.tar.gz: 77fc696bff514db7f944596595a9f6e9773f14cf4993975e4933e9805bf0ab76
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bdf866209e683e9dd48942da0027d8ee008abe7bce256dbc37cdf4809a4394a1a6ce990d5e8d38b3f08222e216d72a814445757144dc9c619938a71a682788c1
|
|
7
|
+
data.tar.gz: f6ffb8669960514dbe4a914a7f6a6f104a902cd746168e6e4e5dfc2140d5034434fd701ed9bb484eea035708940ed04bf10340e24c9aac88659c2f3df08d1d4a
|
data/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,20 @@ All notable changes to this project are documented here. The format follows
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.3.11] - 2026-07-27
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- **Comment import asks only for fields Instagram comments support.** `from{...}` and
|
|
14
|
+
`parent_id` are Facebook-comment fields; one refused field failed the whole call with (#100)
|
|
15
|
+
and zero comments imported. The upsert still uses them opportunistically when Meta sends them,
|
|
16
|
+
and reply nesting derives from the replies expansion itself.
|
|
17
|
+
- **Long reply threads import whole.** The `replies{}` expansion is a single nested page; a
|
|
18
|
+
comment whose thread ran past it silently lost the tail. When the inline page says there is
|
|
19
|
+
more, the comment's replies edge is now walked in full — Instagram threads are two-level,
|
|
20
|
+
so this is the entire conversation.
|
|
21
|
+
|
|
22
|
+
|
|
9
23
|
## [0.3.10] - 2026-07-27
|
|
10
24
|
|
|
11
25
|
### Added
|
|
@@ -12,7 +12,12 @@ module InstagramConnect
|
|
|
12
12
|
|
|
13
13
|
THROTTLE = 10.minutes
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
# Only fields Meta documents for INSTAGRAM comments. from{...} and
|
|
16
|
+
# parent_id are Facebook-comment fields; asking for them can fail the
|
|
17
|
+
# whole call with (#100) — and one refused field means zero comments
|
|
18
|
+
# imported. Reply nesting is derived from the replies expansion itself,
|
|
19
|
+
# and the commenter's igsid still arrives via webhooks.
|
|
20
|
+
REPLY_FIELDS = "id,text,timestamp,username,hidden,like_count".freeze
|
|
16
21
|
COMMENT_FIELDS = "#{REPLY_FIELDS},replies{#{REPLY_FIELDS}}".freeze
|
|
17
22
|
|
|
18
23
|
# One key per post: opening a busy post's comments repeatedly enqueues one
|
|
@@ -38,16 +43,35 @@ module InstagramConnect
|
|
|
38
43
|
|
|
39
44
|
Array(result.data["data"]).each do |item|
|
|
40
45
|
upsert(account, ig_media_id, item)
|
|
41
|
-
|
|
42
|
-
# Meta omits parent_id inside the replies expansion — the nesting
|
|
43
|
-
# itself is the statement.
|
|
44
|
-
upsert(account, ig_media_id, reply.merge("parent_id" => reply["parent_id"] || item["id"]))
|
|
45
|
-
end
|
|
46
|
+
import_replies(account, ig_media_id, item)
|
|
46
47
|
end
|
|
47
48
|
end
|
|
48
49
|
|
|
49
50
|
private
|
|
50
51
|
|
|
52
|
+
# The replies{} expansion is a single nested page. A comment whose thread
|
|
53
|
+
# runs past it gets its replies edge walked in full — Instagram threads
|
|
54
|
+
# are two-level, so this is the whole conversation, not a rabbit hole.
|
|
55
|
+
def import_replies(account, ig_media_id, item)
|
|
56
|
+
inline = Array(item.dig("replies", "data"))
|
|
57
|
+
inline.each do |reply|
|
|
58
|
+
# Meta omits parent_id inside the replies expansion — the nesting
|
|
59
|
+
# itself is the statement.
|
|
60
|
+
upsert(account, ig_media_id, reply.merge("parent_id" => reply["parent_id"] || item["id"]))
|
|
61
|
+
end
|
|
62
|
+
return if item.dig("replies", "paging", "next").blank?
|
|
63
|
+
|
|
64
|
+
walk = account.client.collect("/#{item['id']}/replies",
|
|
65
|
+
{ fields: REPLY_FIELDS, limit: 50 })
|
|
66
|
+
unless walk.success?
|
|
67
|
+
return logger.error("[instagram_connect] replies walk failed for " "comment=#{item['id']}: #{walk.error_message}")
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
Array(walk.data["data"]).each do |reply|
|
|
71
|
+
upsert(account, ig_media_id, reply.merge("parent_id" => reply["parent_id"] || item["id"]))
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
51
75
|
def upsert(account, ig_media_id, item)
|
|
52
76
|
comment = Comment.record(
|
|
53
77
|
account: account,
|
|
@@ -55,7 +79,7 @@ module InstagramConnect
|
|
|
55
79
|
media_id: ig_media_id.to_s,
|
|
56
80
|
text: item["text"],
|
|
57
81
|
from_username: item["username"] || item.dig("from", "username"),
|
|
58
|
-
parent_id: item["parent_id"]
|
|
82
|
+
parent_id: item["parent_id"].presence
|
|
59
83
|
)
|
|
60
84
|
comment.update!(
|
|
61
85
|
from_ig_id: item.dig("from", "id") || comment.from_ig_id,
|