updated plugin ActivityPub
version 5.8.0
This commit is contained in:
@ -7,20 +7,22 @@
|
||||
|
||||
namespace Activitypub\Model;
|
||||
|
||||
use WP_Query;
|
||||
|
||||
use Activitypub\Signature;
|
||||
use Activitypub\Activity\Actor;
|
||||
use Activitypub\Collection\Users;
|
||||
use Activitypub\Collection\Actors;
|
||||
use Activitypub\Collection\Extra_Fields;
|
||||
use Activitypub\Signature;
|
||||
use WP_Query;
|
||||
|
||||
use function Activitypub\esc_hashtag;
|
||||
use function Activitypub\is_single_user;
|
||||
use function Activitypub\is_blog_public;
|
||||
use function Activitypub\get_rest_url_by_path;
|
||||
use function Activitypub\get_attribution_domains;
|
||||
|
||||
/**
|
||||
* Blog class.
|
||||
*
|
||||
* @method int get__id() Gets the internal user ID for the blog (always returns BLOG_USER_ID).
|
||||
*/
|
||||
class Blog extends Actor {
|
||||
/**
|
||||
@ -51,7 +53,7 @@ class Blog extends Actor {
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_id = Users::BLOG_USER_ID; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore
|
||||
protected $_id = Actors::BLOG_USER_ID; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore
|
||||
|
||||
/**
|
||||
* If the User is indexable.
|
||||
@ -89,6 +91,18 @@ class Blog extends Actor {
|
||||
*/
|
||||
protected $posting_restricted_to_mods;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
/**
|
||||
* Fires when a model actor is constructed.
|
||||
*
|
||||
* @param Blog $this The Blog model.
|
||||
*/
|
||||
\do_action( 'activitypub_construct_model_actor', $this );
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the User manually approves followers.
|
||||
*
|
||||
@ -113,13 +127,25 @@ class Blog extends Actor {
|
||||
* @return string The User ID.
|
||||
*/
|
||||
public function get_id() {
|
||||
return $this->get_url();
|
||||
$id = parent::get_id();
|
||||
|
||||
if ( $id ) {
|
||||
return $id;
|
||||
}
|
||||
|
||||
$permalink = \get_option( 'activitypub_use_permalink_as_id_for_blog', false );
|
||||
|
||||
if ( $permalink ) {
|
||||
return $this->get_url();
|
||||
}
|
||||
|
||||
return \add_query_arg( 'author', $this->_id, \trailingslashit( \home_url() ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type of the object.
|
||||
*
|
||||
* If the Blog is in "single user" mode, return "Person" insted of "Group".
|
||||
* If the Blog is in "single user" mode, return "Person" instead of "Group".
|
||||
*
|
||||
* @return string The type of the object.
|
||||
*/
|
||||
@ -197,7 +223,11 @@ class Blog extends Actor {
|
||||
/**
|
||||
* Filters the default blog username.
|
||||
*
|
||||
* @param string $host The default username.
|
||||
* This filter allows developers to modify the default username that is
|
||||
* generated for the blog, which by default is the site's host name
|
||||
* without the 'www.' prefix.
|
||||
*
|
||||
* @param string $host The default username (site's host name).
|
||||
*/
|
||||
return apply_filters( 'activitypub_default_blog_username', $host );
|
||||
}
|
||||
@ -220,7 +250,7 @@ class Blog extends Actor {
|
||||
/**
|
||||
* Get the User icon.
|
||||
*
|
||||
* @return array The User icon.
|
||||
* @return string[] The User icon.
|
||||
*/
|
||||
public function get_icon() {
|
||||
// Try site_logo, falling back to site_icon, first.
|
||||
@ -254,7 +284,7 @@ class Blog extends Actor {
|
||||
/**
|
||||
* Get the User-Header-Image.
|
||||
*
|
||||
* @return array|null The User-Header-Image.
|
||||
* @return string[]|null The User-Header-Image.
|
||||
*/
|
||||
public function get_image() {
|
||||
$header_image = get_option( 'activitypub_header_image' );
|
||||
@ -298,7 +328,7 @@ class Blog extends Actor {
|
||||
$time = \time();
|
||||
}
|
||||
|
||||
return \gmdate( 'Y-m-d\TH:i:s\Z', $time );
|
||||
return \gmdate( ACTIVITYPUB_DATE_TIME_RFC3339, $time );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -339,7 +369,7 @@ class Blog extends Actor {
|
||||
/**
|
||||
* Get the public key information.
|
||||
*
|
||||
* @return array The public key.
|
||||
* @return string[] The public key.
|
||||
*/
|
||||
public function get_public_key() {
|
||||
return array(
|
||||
@ -401,12 +431,12 @@ class Blog extends Actor {
|
||||
/**
|
||||
* Returns endpoints.
|
||||
*
|
||||
* @return array|null The endpoints.
|
||||
* @return string[]|null The endpoints.
|
||||
*/
|
||||
public function get_endpoints() {
|
||||
$endpoints = null;
|
||||
|
||||
if ( ACTIVITYPUB_SHARED_INBOX_FEATURE ) {
|
||||
if ( \get_option( 'activitypub_shared_inbox' ) ) {
|
||||
$endpoints = array(
|
||||
'sharedInbox' => get_rest_url_by_path( 'inbox' ),
|
||||
);
|
||||
@ -497,7 +527,7 @@ class Blog extends Actor {
|
||||
*
|
||||
* @see https://docs.joinmastodon.org/spec/activitypub/#Hashtag
|
||||
*
|
||||
* @return array The User - Hashtags.
|
||||
* @return string[] The User - Hashtags.
|
||||
*/
|
||||
public function get_tag() {
|
||||
$hashtags = array();
|
||||
@ -530,4 +560,41 @@ class Blog extends Actor {
|
||||
$extra_fields = Extra_Fields::get_actor_fields( $this->_id );
|
||||
return Extra_Fields::fields_to_attachments( $extra_fields );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the website hosts allowed to credit this blog.
|
||||
*
|
||||
* @return string[]|null The attribution domains or null if not found.
|
||||
*/
|
||||
public function get_attribution_domains() {
|
||||
return get_attribution_domains();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the alsoKnownAs.
|
||||
*
|
||||
* @return string[] The alsoKnownAs.
|
||||
*/
|
||||
public function get_also_known_as() {
|
||||
$also_known_as = array(
|
||||
\add_query_arg( 'author', $this->_id, \home_url( '/' ) ),
|
||||
$this->get_url(),
|
||||
$this->get_alternate_url(),
|
||||
);
|
||||
|
||||
$also_known_as = array_merge( $also_known_as, \get_option( 'activitypub_blog_user_also_known_as', array() ) );
|
||||
|
||||
return array_unique( $also_known_as );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the movedTo.
|
||||
*
|
||||
* @return string The movedTo.
|
||||
*/
|
||||
public function get_moved_to() {
|
||||
$moved_to = \get_option( 'activitypub_blog_user_moved_to' );
|
||||
|
||||
return $moved_to && $moved_to !== $this->get_id() ? $moved_to : null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user