Improve/webfinger (#616)
* Fix some WebFinger issues * update changelog
This commit is contained in:
parent
a47c9cd7ae
commit
39c9288987
7 changed files with 30 additions and 11 deletions
|
@ -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 ###
|
||||
|
||||
|
|
|
@ -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';
|
||||
}
|
||||
|
|
|
@ -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() ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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 =
|
||||
|
||||
|
|
Loading…
Reference in a new issue