diff --git a/README.md b/README.md index ed1bda8..73223e4 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,8 @@ Project maintained on GitHub at [automattic/wordpress-activitypub](https://githu * Fixed: Normalize attributes that can have mixed value types * Added: URL support for WebFinger * Added: Make Post-Template filterable -* Addes: CSS class for ActivityPub comments to allow custom designs +* Added: CSS class for ActivityPub comments to allow custom designs +* Improved: WebFinger endpoints ### 1.3.0 ### diff --git a/includes/model/class-application-user.php b/includes/model/class-application-user.php index cf4d9cc..c9faded 100644 --- a/includes/model/class-application-user.php +++ b/includes/model/class-application-user.php @@ -38,6 +38,15 @@ class Application_User extends Blog_User { return get_rest_url_by_path( 'application' ); } + /** + * Returns the User-URL with @-Prefix for the username. + * + * @return string The User-URL with @-Prefix for the username. + */ + public function get_alternate_url() { + return \esc_url( \trailingslashit( get_home_url() ) . '@' . $this->get_preferred_username() ); + } + public function get_name() { return 'application'; } diff --git a/includes/model/class-blog-user.php b/includes/model/class-blog-user.php index 21a066e..53f07d4 100644 --- a/includes/model/class-blog-user.php +++ b/includes/model/class-blog-user.php @@ -100,12 +100,12 @@ class Blog_User extends User { } /** - * Returns the User-URL with @-Prefix for the username. + * Get blog's homepage URL. * - * @return string The User-URL with @-Prefix for the username. + * @return string The User-Url. */ - public function get_at_url() { - return \esc_url( \trailingslashit( get_home_url() ) . '@' . $this->get_preferred_username() ); + public function get_alternate_url() { + return \esc_url( \trailingslashit( get_home_url() ) ); } /** diff --git a/includes/model/class-user.php b/includes/model/class-user.php index 95c83d7..c713434 100644 --- a/includes/model/class-user.php +++ b/includes/model/class-user.php @@ -135,8 +135,8 @@ class User extends Actor { * * @return string The User-URL with @-Prefix for the username. */ - public function get_at_url() { - return \esc_url( \trailingslashit( get_home_url() ) . '@' . $this->get_username() ); + public function get_alternate_url() { + return \esc_url( \trailingslashit( get_home_url() ) . '@' . $this->get_preferred_username() ); } public function get_preferred_username() { diff --git a/includes/rest/class-webfinger.php b/includes/rest/class-webfinger.php index 52abd9f..765044b 100644 --- a/includes/rest/class-webfinger.php +++ b/includes/rest/class-webfinger.php @@ -94,10 +94,13 @@ class Webfinger { $aliases = array( $user->get_url(), + $user->get_alternate_url(), ); + $aliases = array_unique( $aliases ); + $profile = array( - 'subject' => $resource, + 'subject' => sprintf( 'acct:%s', $user->get_resource() ), 'aliases' => array_values( array_unique( $aliases ) ), 'links' => array( array( diff --git a/integration/class-webfinger.php b/integration/class-webfinger.php index 6b3b6dd..e5fdd5d 100644 --- a/integration/class-webfinger.php +++ b/integration/class-webfinger.php @@ -14,8 +14,8 @@ class Webfinger { * Initialize the class, registering WordPress hooks */ public static function init() { - \add_filter( 'webfinger_user_data', array( self::class, 'add_user_discovery' ), 10, 3 ); - \add_filter( 'webfinger_data', array( self::class, 'add_pseudo_user_discovery' ), 99, 2 ); + \add_filter( 'webfinger_user_data', array( self::class, 'add_user_discovery' ), 1, 3 ); + \add_filter( 'webfinger_data', array( self::class, 'add_pseudo_user_discovery' ), 1, 2 ); } /** @@ -34,6 +34,11 @@ class Webfinger { return $array; } + $array['subject'] = sprintf( 'acct:%s', $user->get_resource() ); + + $array['aliases'][] = $user->get_url(); + $array['aliases'][] = $user->get_alternate_url(); + $array['links'][] = array( 'rel' => 'self', 'type' => 'application/activity+json', diff --git a/readme.txt b/readme.txt index 93885ae..e0797d2 100644 --- a/readme.txt +++ b/readme.txt @@ -111,7 +111,8 @@ Project maintained on GitHub at [automattic/wordpress-activitypub](https://githu * Fixed: Normalize attributes that can have mixed value types * Added: URL support for WebFinger * Added: Make Post-Template filterable -* Addes: CSS class for ActivityPub comments to allow custom designs +* Added: CSS class for ActivityPub comments to allow custom designs +* Improved: WebFinger endpoints = 1.3.0 =