Skip to content

Interactions: Accept webfinger IDs #1834

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

Merged
merged 3 commits into from
Jun 19, 2025
Merged

Conversation

obenland
Copy link
Member

Fixes #1831.
Introduced in #1149.

Proposed changes:

  • Replaces uri formatting from uri parameter with sanitization callback.
  • Adds unit test for accepting webfinger IDs.

Other information:

  • Have you written new tests for your changes, if applicable?

Testing instructions:

Changelog entry

  • Automatically create a changelog entry from the details below.
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Added - for new features
  • Changed - for changes in existing functionality
  • Deprecated - for soon-to-be removed features
  • Removed - for now removed features
  • Fixed - for any bug fixes
  • Security - in case of vulnerabilities

Message

Interaction attempts that pass a webfinger ID instead of a URL will work again.

@obenland obenland requested review from pfefferle and akirk June 18, 2025 19:09
@obenland obenland self-assigned this Jun 18, 2025
@Copilot Copilot AI review requested due to automatic review settings June 18, 2025 19:09
Copy link

@Copilot Copilot AI left a 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 enables the interactions endpoint to accept Webfinger IDs (e.g., user@domain) in addition to URLs by adding a sanitization callback, updating the route schema, and covering the new behavior with a unit test.

  • Introduce sanitize_uri() to trim leading “@” and choose between email or URL sanitizers.
  • Update uri argument description and remove the strict URI format check.
  • Add a REST endpoint test that uses a Webfinger ID and expects the appropriate exception.
Comments suppressed due to low confidence (2)

tests/includes/rest/class-test-interaction-controller.php:129

  • The test expects an exception message but doesn’t specify the exception class. Add $this->expectException(\WP_REST_Exception::class); before this line to ensure the exception is properly caught.
		$this->expectExceptionMessage( 'This Interaction type is not supported yet!' );

tests/includes/rest/class-test-interaction-controller.php:127

  • [nitpick] Consider adding direct unit tests for sanitize_uri() itself to cover inputs like leading '@', pure URLs, invalid emails, and 'acct:' prefixes, rather than relying only on dispatch behavior.
		$request->set_param( 'uri', 'activitypub.blog@activitypub.blog' );

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@obenland obenland merged commit b724ebe into trunk Jun 19, 2025
11 checks passed
@obenland obenland deleted the update/interaction-webfinger branch June 19, 2025 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Interactions REST API not compatible with Mastodon-style / Webfinger usernames
3 participants