Conversation
…gagement
ListComments read one page of GET /{object-id}/comments without an
order. With the default top-level filter the Graph API lists comments
oldest first, so once a post had more comments than one page, every
poll returned the same oldest page and new comments never reached the
inbox. Ask for reverse_chronological order, as the YouTube adapter
already does with order=time.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 4 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe Facebook adapter now requests top-level comments in reverse chronological order. Tests cover retrieval when comments exceed one page. The changelog records the fix for busy Facebook posts. ChangesFacebook comment ordering
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The newest comments are requested and covered by a focused paginated-response test. No actionable merge risk remains. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
FacebookAdapter.ListCommentsread a single page ofGET /{object-id}/commentsand passed noorder. With the defaulttoplevelfilter the Graph API lists comments oldest first. Once a post had more comments than fit on one page, every engagement poll got back the same oldest page, and no later comment ever reached the inbox. The fix requestsorder=reverse_chronological, so the page holds the newest comments.Motivation
The engagement inbox is incremental.
persistEngagementCommentupserts what each poll returns and never removes comments that a later poll no longer lists. So what matters is that each poll sees the newest comments; older ones were already stored when they were new. Reading oldest first gets this backwards, and it happens on exactly the posts that get the most engagement.Graph API reference for the comments edge:
filter: "toplevel- This is the default. It returns all top-level comments in chronological order, as ordered on Facebook."order:chronologicalis "Comments sorted by the oldest comments first", andreverse_chronologicalis "Comments sorted by the newest comments first."nextlink no longer appears"), and the adapter reads only the first page.I kept it to the ordering rather than following
paging.next. That keeps each poll to one request, which matters for fresh posts that are polled every five minutes. It is the same approach the YouTube adapter already takes withorder=timeoncommentThreads.Testing
go test ./internal/platform/...)bun run --filter @openpost/web test): no frontend changego vet,gofmt,gofumpt,golangci-lint run ./internal/platform/...: 0 issues, same asmain)TestFacebookListCommentsReadsNewestCommentsFirstserves the edge the way the reference describes it. The post has 30 comments and each page holds 25, listed oldest first unlessorder=reverse_chronologicalis sent. The test checks that the newest comment is collected. The existingTestFacebookListCommentsMarksPageCommentsAsOursstill passes.Fails on unmodified
main:Passes with the fix.
go test ./internal/platform/...isok, andgo build -tags dev ./...is clean.go test -coverprofileshows the changed line runs under the new test. I have not tested this against a live Page. The behavior is taken from the Graph API reference quoted above.Checklist
changes/facebook-newest-comments.mdBreaking Changes
Affected Components
Platform Impact
🤖 Generated with Claude Code
Summary by CodeRabbit