updated plugin ActivityPub version 0.13.0

This commit is contained in:
2021-07-25 23:24:56 +00:00
committed by Gitium
parent e0e2392c3c
commit e80e4be44b
15 changed files with 567 additions and 111 deletions

View File

@ -21,7 +21,7 @@ class Following {
*/
public static function register_routes() {
\register_rest_route(
'activitypub/1.0', '/users/(?P<id>\d+)/following', array(
'activitypub/1.0', '/users/(?P<user_id>\d+)/following', array(
array(
'methods' => \WP_REST_Server::READABLE,
'callback' => array( '\Activitypub\Rest\Following', 'get' ),
@ -40,7 +40,7 @@ class Following {
* @return WP_REST_Response
*/
public static function get( $request ) {
$user_id = $request->get_param( 'id' );
$user_id = $request->get_param( 'user_id' );
$user = \get_user_by( 'ID', $user_id );
if ( ! $user ) {
@ -61,14 +61,17 @@ class Following {
$json->{'@context'} = \Activitypub\get_context();
$json->id = \home_url( \add_query_arg( null, null ) );
$json->generator = 'http://wordpress.org/?v=' . \get_bloginfo_rss( 'version' );
$json->actor = \get_author_posts_url( $user_id );
$json->type = 'OrderedCollectionPage';
$json->partOf = \get_rest_url( null, "/activitypub/1.0/users/$user_id/following" ); // phpcs:ignore
$json->totalItems = 0; // phpcs:ignore
$json->orderedItems = array(); // phpcs:ignore
$json->orderedItems = apply_filters( 'activitypub_following', array(), $user ); // phpcs:ignore
$json->first = $json->partOf; // phpcs:ignore
$json->first = \get_rest_url( null, "/activitypub/1.0/users/$user_id/following" );
$response = new \WP_REST_Response( $json, 200 );
$response->header( 'Content-Type', 'application/activity+json' );
@ -87,7 +90,7 @@ class Following {
'type' => 'integer',
);
$params['id'] = array(
$params['user_id'] = array(
'required' => true,
'type' => 'integer',
);