add @-urls to webfinger aliases

This commit is contained in:
Matthias Pfefferle 2023-05-30 11:37:21 +02:00
parent 2feca1388a
commit 7b9b3dbc37
2 changed files with 12 additions and 4 deletions

View file

@ -100,6 +100,10 @@ class User {
return $this->get_url(); return $this->get_url();
} }
public function get_at_url() {
return \esc_url( \trailingslashit( get_home_url() ) . '@' . $this->get_username() );
}
public function get_username() { public function get_username() {
return \esc_attr( \get_the_author_meta( 'login', $this->user_id ) ); return \esc_attr( \get_the_author_meta( 'login', $this->user_id ) );
} }

View file

@ -53,12 +53,16 @@ class Webfinger {
return $user; return $user;
} }
$aliases = array(
$user->get_url(),
$user->get_canonical_url(),
$user->get_at_url(),
);
$json = array( $json = array(
'subject' => $resource, 'subject' => $resource,
'aliases' => array( 'aliases' => array_values( array_unique( $aliases ) ),
$user->get_url(), 'links' => array(
),
'links' => array(
array( array(
'rel' => 'self', 'rel' => 'self',
'type' => 'application/activity+json', 'type' => 'application/activity+json',