-
Notifications
You must be signed in to change notification settings - Fork 85
Implement FEP-8fcf followers collection synchronization #2297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Adds support for FEP-8fcf to synchronize followers collections across servers. This includes generating and processing Collection-Synchronization headers, computing partial follower digests, exposing a new /followers-sync REST endpoint, and scheduling async reconciliation jobs when mismatches are detected. New methods and traits are introduced for digest computation, header parsing, and reconciliation, with hooks for monitoring sync events. This improves data consistency and interoperability with other ActivityPub servers supporting FEP-8fcf.
Included a reference to FEP-8fcf (Followers collection synchronization across servers) in the list of supported FEPs to reflect updated protocol support.
Moved FEP-8fcf Collection-Synchronization header parsing and validation from Followers class to Http class, and generalized synchronization handling into the Collection trait. Removed the Followers_Sync trait and updated controllers to use the new process_collection_synchronization method. This refactor enables support for synchronizing additional collection types beyond followers and centralizes related logic for easier maintenance.
Changed the REST endpoint path from /followers-sync to /followers/sync in documentation, URL generation, and route registration to ensure consistency and clarity in the API.
Refactored code to remove redundant '\Activitypub\' class name prefixes when calling static methods within the same namespace. This improves code readability and consistency.
Moved Collection-Synchronization (FEP-8fcf) logic from REST controllers and trait to a dedicated handler class (Collection_Sync). Removed related code from trait-collection.php, class-http.php, and REST controllers, and registered the new handler in class-handler.php. This improves separation of concerns and centralizes collection sync logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements FEP-8fcf (Followers collection synchronization across servers) to improve data consistency and interoperability with other ActivityPub servers. The implementation adds Collection-Synchronization headers to outgoing activities, provides endpoints for partial follower collections, and includes async reconciliation when digest mismatches are detected.
Key changes:
- Adds Collection-Synchronization header generation and processing for FEP-8fcf protocol
- Implements partial follower digest computation using XOR'd SHA256 hashes
- Provides new
/followers-syncREST endpoint for synchronization - Includes async reconciliation scheduler for handling digest mismatches
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| includes/scheduler/class-follower.php | New scheduler for handling async follower reconciliation |
| includes/rest/class-inbox-controller.php | Adds Collection trait for synchronization support |
| includes/rest/class-followers-controller.php | Implements new /followers/sync endpoint for partial collections |
| includes/handler/class-collection-sync.php | New handler for processing Collection-Synchronization headers |
| includes/collection/class-remote-actors.php | Fixes missing namespace import for Webfinger |
| includes/collection/class-followers.php | Adds FEP-8fcf digest computation and partial followers methods |
| includes/class-scheduler.php | Registers new Follower scheduler |
| includes/class-http.php | Adds Collection-Synchronization header to outgoing activities |
| includes/class-handler.php | Registers new Collection_Sync handler |
| docs/fep-8fcf-implementation.md | Documentation for FEP-8fcf implementation |
| FEDERATION.md | Updates supported FEPs list |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Introduces 'page', 'per_page', and 'order' parameters to the followers sync REST endpoint for improved pagination and sorting. Updates the controller to handle these parameters and enhances test coverage with extensive e2e tests for pagination, authority filtering, error handling, and response consistency. Also updates Playwright config to ensure proper rewrite structure for test environment.
Deleted the static get_authority method from Collection_Sync as it is no longer used in the codebase.
Corrects the regular expression in detect_collection_type to match '/followers/sync' instead of '/followers-sync', ensuring accurate detection of followers collections.
The webServer command now runs an additional command to set the WordPress permalink structure to '/postname' after starting the environment. This ensures tests run with the correct permalink settings.
Added a 'wp rewrite flush' command to the Playwright webServer setup to ensure rewrite rules are properly applied before running tests.
Removed the old 'fep-8fcf-implementation.md' and added a new, more comprehensive 'collection-synchronization.md' documentation. The new doc provides detailed information on the FEP-8fcf prototype, including implementation details, REST endpoints, privacy considerations, action hooks, compatibility, testing, and future enhancements.
Removed additional WordPress CLI commands from the webServer command, leaving only 'npm run env-start' for environment setup.
Moved test cases out of nested blocks in the 'Partial Followers Sync Endpoint' and 'Collection Response Format' suites for improved readability and consistency. No logic changes were made.
Updated the afterStart lifecycle script to flush rewrite rules after setting the permalink structure, ensuring changes take effect immediately.
The Collection trait was removed from the Inbox_Controller class as it is no longer used. This helps clean up the code and avoid unnecessary dependencies.
Consolidated the default value note for the frequency parameter into the @param line in the docblock for clarity.
Introduces a transient cache to prevent duplicate collection syncs per user and actor. Refactors frequency logic into a new get_frequency() method for consistency and maintainability.
|
@obenland now it runs only once a week (outgoing and incoming). |
Updated Followers::compute_partial_digest() to delegate digest computation to Signature::compute_collection_digest(), improving code reuse and consistency. Updated documentation in both the code and collection-synchronization.md to reflect this change and clarify method responsibilities.
Co-authored-by: Konstantin Obenland <obenland@gmx.de>
Refactored the Signature class method compute_collection_digest to get_collection_digest for clarity and consistency. Updated all references and documentation to use the new method name.
Deleted docs/collection-synchronization.md, which described the FEP-8fcf followers collection synchronization implementation, its components, API, and testing instructions.
The get_url_authority function now returns only the scheme and host, omitting the port even if specified. This simplifies the function and matches the updated docblock.
Changed the default value of user_id from 0 to false and updated the conditional check to use strict comparison. This ensures that user_id is properly validated before proceeding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, just a couple of minor things I noticed, then it should be good to go
Co-authored-by: Konstantin Obenland <obenland@gmx.de>
Co-authored-by: Konstantin Obenland <obenland@gmx.de>
Co-authored-by: Konstantin Obenland <obenland@gmx.de>
Co-authored-by: Konstantin Obenland <obenland@gmx.de>
Co-authored-by: Konstantin Obenland <obenland@gmx.de>
Adds support for FEP-8fcf to synchronize followers collections across servers. This includes generating and processing Collection-Synchronization headers, computing partial follower digests, exposing a new /followers-sync REST endpoint, and scheduling async reconciliation jobs when mismatches are detected. New methods and traits are introduced for digest computation, header parsing, and reconciliation, with hooks for monitoring sync events. This improves data consistency and interoperability with other ActivityPub servers supporting FEP-8fcf.
Proposed changes:
/followers/syncREST endpoint for synchronizationOther information:
Testing instructions:
Changelog entry
Changelog Entry Details
Significance
Type
Message
Added support for FEP-8fcf follower synchronization, improving data consistency across servers with new sync headers, digest checks, and reconciliation tasks.