updated plugin ActivityPub
version 2.2.0
This commit is contained in:
@ -15,19 +15,17 @@ class Application_User extends Blog_User {
|
||||
*/
|
||||
protected $_id = Users::APPLICATION_USER_ID; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore
|
||||
|
||||
/**
|
||||
* The User-Type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type = 'Application';
|
||||
public function get_type() {
|
||||
return 'Application';
|
||||
}
|
||||
|
||||
/**
|
||||
* If the User is discoverable.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $discoverable = false;
|
||||
public function get_discoverable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function get_manually_approves_followers() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the User-Url.
|
||||
@ -52,7 +50,7 @@ class Application_User extends Blog_User {
|
||||
}
|
||||
|
||||
public function get_preferred_username() {
|
||||
return $this::get_name();
|
||||
return $this->get_name();
|
||||
}
|
||||
|
||||
public function get_followers() {
|
||||
@ -78,8 +76,4 @@ class Application_User extends Blog_User {
|
||||
public function get_indexable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function get_type() {
|
||||
return $this->type;
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,8 @@
|
||||
namespace Activitypub\Model;
|
||||
|
||||
use WP_Query;
|
||||
use Activitypub\Signature;
|
||||
use WP_Error;
|
||||
|
||||
use Activitypub\Collection\Users;
|
||||
|
||||
use function Activitypub\is_single_user;
|
||||
@ -17,19 +18,13 @@ class Blog_User extends User {
|
||||
*/
|
||||
protected $_id = Users::BLOG_USER_ID; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore
|
||||
|
||||
/**
|
||||
* The User-Type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type = null;
|
||||
public function get_manually_approves_followers() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Account discoverable?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $discoverable = true;
|
||||
public function get_discoverable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function from_wp_user( $user_id ) {
|
||||
if ( is_user_disabled( $user_id ) ) {
|
||||
|
@ -162,8 +162,10 @@ class Follower extends Actor {
|
||||
}
|
||||
}
|
||||
|
||||
$post_id = $this->get__id();
|
||||
|
||||
$args = array(
|
||||
'ID' => $this->get__id(),
|
||||
'ID' => $post_id,
|
||||
'guid' => esc_url_raw( $this->get_id() ),
|
||||
'post_title' => wp_strip_all_tags( sanitize_text_field( $this->get_name() ) ),
|
||||
'post_author' => 0,
|
||||
@ -174,6 +176,14 @@ class Follower extends Actor {
|
||||
'meta_input' => $this->get_post_meta_input(),
|
||||
);
|
||||
|
||||
if ( ! empty( $post_id ) ) {
|
||||
// If this is an update, prevent the "followed" date from being
|
||||
// overwritten by the current date.
|
||||
$post = get_post( $post_id );
|
||||
$args['post_date'] = $post->post_date;
|
||||
$args['post_date_gmt'] = $post->post_date_gmt;
|
||||
}
|
||||
|
||||
$post_id = wp_insert_post( $args );
|
||||
$this->_id = $post_id;
|
||||
|
||||
@ -286,6 +296,25 @@ class Follower extends Actor {
|
||||
return $icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Icon URL (Avatar)
|
||||
*
|
||||
* @return string The URL to the Avatar.
|
||||
*/
|
||||
public function get_image_url() {
|
||||
$image = $this->get_image();
|
||||
|
||||
if ( ! $image ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ( is_array( $image ) ) {
|
||||
return $image['url'];
|
||||
}
|
||||
|
||||
return $image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the shared inbox, with a fallback to the inbox.
|
||||
*
|
||||
|
@ -23,6 +23,11 @@ class User extends Actor {
|
||||
*
|
||||
* @see https://docs.joinmastodon.org/spec/activitypub/#featured
|
||||
*
|
||||
* @context {
|
||||
* "@id": "http://joinmastodon.org/ns#featured",
|
||||
* "@type": "@id"
|
||||
* }
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $featured;
|
||||
@ -36,18 +41,17 @@ class User extends Actor {
|
||||
*/
|
||||
protected $moderators;
|
||||
|
||||
/**
|
||||
* The User-Type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type = 'Person';
|
||||
public function get_type() {
|
||||
return 'Person';
|
||||
}
|
||||
|
||||
/**
|
||||
* If the User is discoverable.
|
||||
*
|
||||
* @see https://docs.joinmastodon.org/spec/activitypub/#discoverable
|
||||
*
|
||||
* @context http://joinmastodon.org/ns#discoverable
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $discoverable = true;
|
||||
@ -55,6 +59,8 @@ class User extends Actor {
|
||||
/**
|
||||
* If the User is indexable.
|
||||
*
|
||||
* @context http://joinmastodon.org/ns#indexable
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $indexable;
|
||||
|
Reference in New Issue
Block a user