Merged
Conversation
845d408 to
0319c5a
Compare
Move pagination from fetch_notifications into finalize_notifications (priority 100) so it applies to the merged set from all notification providers, not just the internal handler. This adds proper sorting by ID descending before paginating with min_id/max_id/since_id/limit and setting Link headers per the Mastodon API spec. - Rename normalize_notification_ids to finalize_notifications - Add get_notification_value helper for array/entity access - Align default limit to 40, max 80 per Mastodon API spec
Switch from raw header() calls to WP_REST_Response::add_link() for notification pagination, matching the pattern used by the timeline endpoint. This makes Link headers testable via $response->get_links() in PHPUnit. Add notification pagination tests covering sorting, limit, max_id, min_id, since_id, combined parameters, Link headers, and forward pagination walk-through.
The Mastodon API spec says since_id returns results "greater than this ID". The comparison used > which didn't break on equality, letting the item with id == since_id slip through. Changed to >= to match min_id behavior and the spec.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Mastodon clients rely on notification IDs being sortable and comparable strings for pagination. When multiple notification sources exist (e.g. the built-in handler and the ActivityPub plugin), each produces its own ID format, which means clients can't paginate correctly — they miss notifications, show them out of order, or get stuck in pagination loops.
This PR unifies notification IDs to a date-based format across all sources and centralizes sorting and pagination so it works over the merged set.
Changes
fetch_notificationsintofinalize_notifications(priority 100 filter), so it applies after all sources have contributedmax_id,since_id,min_id, andlimitper the Mastodon API spec (default limit 40, max 80)WP_REST_Response::add_link()for pagination Link headers, matching the timeline endpoint patternstatusfield nullable on the Notification entity (follow notifications have no status)>=coerces 28+ digit numeric strings to float (only ~15 digits precision), breaking pagination for same-day notifications. Addid_cmp()helper that left-pads to equal length for correctstrcmpif-modified-sinceheader to compare as numeric ID instead of date stringTest plan