updated plugin ActivityPub
version 2.4.0
This commit is contained in:
@ -5,9 +5,9 @@ use stdClass;
|
||||
use WP_Error;
|
||||
use WP_REST_Server;
|
||||
use WP_REST_Response;
|
||||
use Activitypub\Transformer\Post;
|
||||
use Activitypub\Activity\Activity;
|
||||
use Activitypub\Collection\Users as User_Collection;
|
||||
use Activitypub\Transformer\Factory;
|
||||
|
||||
use function Activitypub\get_context;
|
||||
use function Activitypub\get_rest_url_by_path;
|
||||
@ -34,7 +34,7 @@ class Outbox {
|
||||
public static function register_routes() {
|
||||
\register_rest_route(
|
||||
ACTIVITYPUB_REST_NAMESPACE,
|
||||
'/users/(?P<user_id>[\w\-\.]+)/outbox',
|
||||
'/(users|actors)/(?P<user_id>[\w\-\.]+)/outbox',
|
||||
array(
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
@ -72,11 +72,11 @@ class Outbox {
|
||||
$json = new stdClass();
|
||||
|
||||
$json->{'@context'} = get_context();
|
||||
$json->id = get_rest_url_by_path( sprintf( 'users/%d/outbox', $user_id ) );
|
||||
$json->id = get_rest_url_by_path( sprintf( 'actors/%d/outbox', $user_id ) );
|
||||
$json->generator = 'http://wordpress.org/?v=' . get_masked_wp_version();
|
||||
$json->actor = $user->get_id();
|
||||
$json->type = 'OrderedCollectionPage';
|
||||
$json->partOf = get_rest_url_by_path( sprintf( 'users/%d/outbox', $user_id ) ); // phpcs:ignore
|
||||
$json->partOf = get_rest_url_by_path( sprintf( 'actors/%d/outbox', $user_id ) ); // phpcs:ignore
|
||||
$json->totalItems = 0; // phpcs:ignore
|
||||
|
||||
if ( $user_id > 0 ) {
|
||||
@ -111,7 +111,13 @@ class Outbox {
|
||||
);
|
||||
|
||||
foreach ( $posts as $post ) {
|
||||
$post = Post::transform( $post )->to_object();
|
||||
$transformer = Factory::get_transformer( $post );
|
||||
|
||||
if ( \is_wp_error( $transformer ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$post = $transformer->to_object();
|
||||
$activity = new Activity();
|
||||
$activity->set_type( 'Create' );
|
||||
$activity->set_object( $post );
|
||||
|
Reference in New Issue
Block a user