updated plugin ActivityPub version 8.3.0

This commit is contained in:
2026-06-03 21:28:46 +00:00
committed by Gitium
parent a4b78ec277
commit 6fe182458a
340 changed files with 43232 additions and 7568 deletions

View File

@ -8,13 +8,12 @@
namespace Activitypub\Model;
use Activitypub\Activity\Actor;
use Activitypub\Collection\Actors;
use Activitypub\Collection\Extra_Fields;
use Activitypub\Http;
use Activitypub\Signature;
use function Activitypub\is_blog_public;
use function Activitypub\get_rest_url_by_path;
use function Activitypub\get_attribution_domains;
use function Activitypub\get_rest_url_by_path;
use function Activitypub\is_blog_public;
use function Activitypub\user_can_activitypub;
/**
@ -30,20 +29,6 @@ class User extends Actor {
*/
protected $_id; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore
/**
* The Featured-Posts.
*
* @see https://docs.joinmastodon.org/spec/activitypub/#featured
*
* @context {
* "@id": "http://joinmastodon.org/ns#featured",
* "@type": "@id"
* }
*
* @var string
*/
protected $featured;
/**
* Whether the User is discoverable.
*
@ -56,20 +41,22 @@ class User extends Actor {
protected $discoverable = true;
/**
* Whether the User is indexable.
* The generator of the object.
*
* @context http://joinmastodon.org/ns#indexable
* @see https://www.w3.org/TR/activitypub/#generator
* @see https://codeberg.org/fediverse/fep/src/branch/main/fep/844e/fep-844e.md#discovery-through-an-actor
*
* @var boolean
* @var array
*/
protected $indexable;
/**
* The WebFinger Resource.
*
* @var string
*/
protected $webfinger;
protected $generator = array(
'type' => 'Application',
'implements' => array(
array(
'href' => 'https://datatracker.ietf.org/doc/html/rfc9421',
'name' => 'RFC-9421: HTTP Message Signatures',
),
),
);
/**
* Constructor.
@ -135,7 +122,7 @@ class User extends Actor {
return $this->get_url();
}
return \add_query_arg( 'author', $this->_id, \trailingslashit( \home_url() ) );
return \add_query_arg( 'author', $this->_id, \home_url( '/' ) );
}
/**
@ -184,7 +171,14 @@ class User extends Actor {
* @return string The preferred username.
*/
public function get_preferred_username() {
return \get_the_author_meta( 'login', $this->_id );
$login = \get_the_author_meta( 'login', $this->_id );
// Handle cases where login is an email address (e.g., from Site Kit Google login).
if ( \filter_var( $login, FILTER_VALIDATE_EMAIL ) ) {
$login = \get_the_author_meta( 'user_nicename', $this->_id );
}
return $login;
}
/**
@ -259,7 +253,7 @@ class User extends Actor {
return array(
'id' => $this->get_id() . '#main-key',
'owner' => $this->get_id(),
'publicKeyPem' => Signature::get_public_key_for( $this->get__id() ),
'publicKeyPem' => Actors::get_public_key( $this->get__id() ),
);
}
@ -299,6 +293,17 @@ class User extends Actor {
return get_rest_url_by_path( sprintf( 'actors/%d/following', $this->get__id() ) );
}
/**
* Returns the Liked API endpoint.
*
* @since 8.1.0
*
* @return string The Liked endpoint.
*/
public function get_liked() {
return get_rest_url_by_path( sprintf( 'actors/%d/liked', $this->get__id() ) );
}
/**
* Returns the Featured-API-Endpoint.
*
@ -308,21 +313,29 @@ class User extends Actor {
return get_rest_url_by_path( sprintf( 'actors/%d/collections/featured', $this->get__id() ) );
}
/**
* Returns the Featured-Tags-API-Endpoint.
*
* @return string The Featured-Tags-Endpoint.
*/
public function get_featured_tags() {
return get_rest_url_by_path( sprintf( 'actors/%d/collections/tags', $this->get__id() ) );
}
/**
* Returns the endpoints.
*
* @return string[]|null The endpoints.
*/
public function get_endpoints() {
$endpoints = null;
if ( \get_option( 'activitypub_shared_inbox' ) ) {
$endpoints = array(
'sharedInbox' => get_rest_url_by_path( 'inbox' ),
);
}
return $endpoints;
return array(
'sharedInbox' => get_rest_url_by_path( 'inbox' ),
'oauthAuthorizationEndpoint' => get_rest_url_by_path( 'oauth/authorize' ),
'oauthTokenEndpoint' => get_rest_url_by_path( 'oauth/token' ),
'oauthRegistrationEndpoint' => get_rest_url_by_path( 'oauth/clients' ),
'proxyUrl' => get_rest_url_by_path( 'proxy' ),
'proxyEventStream' => get_rest_url_by_path( 'proxy/stream' ),
);
}
/**
@ -455,7 +468,6 @@ class User extends Actor {
$this->get_alternate_url(),
);
// phpcs:ignore Universal.Operators.DisallowShortTernary.Found
$also_known_as = array_merge( $also_known_as, \get_user_option( 'activitypub_also_known_as', $this->_id ) ?: array() );
return array_unique( $also_known_as );