From b07ffb9a7c9ae12b2ac405731e4781c0abee2423 Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Wed, 22 Aug 2018 08:33:06 -0400 Subject: [PATCH] Flesh out user actor profile --- inc/actors.php | 19 ++++++++++++------- inc/api.php | 8 ++++---- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/inc/actors.php b/inc/actors.php index 4be04a3..c597486 100644 --- a/inc/actors.php +++ b/inc/actors.php @@ -1,17 +1,22 @@ get('ID')); $actor = array( "@context" => array( "https://www.w3.org/ns/activitystreams" ), "type" => "Person", - "id" => get_rest_url( null, sprintf( '/activitypub/v1/user/%s', $handle ) ), - "following" => "TODO", // link to following JSON - "followers" => "TODO", // link to followers JSON - "liked" => "TODO", // link to liked JSON - "inbox" => "TODO", // link to inbox JSON - "outbox" => "TODO", // link to outbox JSON + "id" => get_rest_url( null, sprintf( '/activitypub/v1/actor/%s', $handle ) ), + "following" => get_rest_url( + null, sprintf( '/activitypub/v1/actor/%s/following', $handle ) ), + "followers" => get_rest_url( + null, sprintf( '/activitypub/v1/actor/%s/followers', $handle ) ), + "liked" => get_rest_url( + null, sprintf( '/activitypub/v1/actor/%s/liked', $handle ) ), + "inbox" => get_rest_url( + null, sprintf( '/activitypub/v1/actor/%s/inbox', $handle ) ), + "outbox" => get_rest_url( + null, sprintf( '/activitypub/v1/actor/%s/outbox', $handle ) ), "preferredUsername" => $handle, "name" => get_the_author_meta( 'display_name', $user->get('ID') ), "summary" => get_the_author_meta( 'description', $user->get('ID') ), diff --git a/inc/api.php b/inc/api.php index eef6c83..08dac34 100644 --- a/inc/api.php +++ b/inc/api.php @@ -3,16 +3,16 @@ namespace api; require_once plugin_dir_path( __FILE__ ) . '/actors.php'; -function get_user( $data ) { +function get_user_actor( $data ) { $handle = $data["handle"]; $id = get_user_by( 'slug', $handle ); - return \actors\author_to_user( $id ); + return \actors\user_to_actor( $id ); } function register_routes() { - register_rest_route( 'activitypub/v1', '/user/(?P[a-zA-Z0-9-]+)', array( + register_rest_route( 'activitypub/v1', '/actor/(?P[a-zA-Z0-9-]+)', array( 'methods' => 'GET', - 'callback' => __NAMESPACE__ . '\get_user', + 'callback' => __NAMESPACE__ . '\get_user_actor', ) ); } ?>