-
Notifications
You must be signed in to change notification settings - Fork 82
Add fetch_by_acct
and fetch_by_various
methods to Remote_Actors
#2235
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
Introduces fetch_by_acct to retrieve remote actor posts by acct identifier, resolving via Webfinger and fetching remotely if not found locally. Adds fetch_by_various to select between URI and acct-based fetching. Comprehensive tests for both methods are included, covering local, remote, and error scenarios.
Improves input validation in Remote_Actors by checking if the identifier matches the expected username pattern before calling fetch_by_acct. Returns a WP_Error with status 400 if the identifier is invalid.
Replaces Http::get_remote_object with Remote_Actors::fetch_by_various for fetching remote actor metadata. Adds error handling for WP_Error and decodes the actor's post_content as JSON before returning. Also adds a phpcs ignore comment for unused variables.
fetch_by_acct
and fetch_by_various
methods to Remote_Actors
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 adds new methods to fetch remote actors by different identifier types, enhancing the flexibility of actor retrieval in the ActivityPub plugin.
- Introduces
fetch_by_acct
method to retrieve actors via webfinger resolution of acct identifiers - Adds
fetch_by_various
method as a unified interface to select between URI and acct-based fetching - Updates
get_remote_metadata_by_actor
to use the newfetch_by_various
method instead of direct HTTP calls
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
includes/collection/class-remote-actors.php | Implements new fetch_by_acct and fetch_by_various methods with webfinger resolution |
includes/functions.php | Updates get_remote_metadata_by_actor to use new actor fetching methods |
tests/includes/collection/class-test-remote-actors.php | Adds comprehensive test coverage for new methods including error scenarios |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <[email protected]>
I’m a bit surprised that replacing the logic of |
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.
Neat
Introduces
fetch_by_acct
to retrieve remote actor posts by acct identifier, resolving via Webfinger and fetching remotely if not found locally. Addsfetch_by_various
to select between URI and acct-based fetching. Comprehensive tests for both methods are included, covering local, remote, and error scenarios.In preparation to #2225
This PR introduces the least invasive change needed to cache all Actors in the ap_actor post type. It also adds the necessary functions to update the rest of the code and deprecates
get_remote_metadata_by_actor
.Proposed changes:
fetch_by_acct
method to retrieve actors via webfinger resolution of acct identifiersfetch_by_various
method as a unified interface to select between URI and acct-based fetchingget_remote_metadata_by_actor
to use the newfetch_by_various
method instead of direct HTTP callsOther information:
Testing instructions:
Changelog entry
Changelog Entry Details
Significance
Type
Message
Added support for fetching actors by account identifiers and improved reliability of actor retrieval.