service actor as application actor

This commit is contained in:
Django Doucet 2023-05-05 12:09:12 -06:00
parent 27636b62d5
commit e827221ee6

View file

@ -27,11 +27,11 @@ class Server {
public static function register_routes() { public static function register_routes() {
\register_rest_route( \register_rest_route(
'activitypub/1.0', 'activitypub/1.0',
'/service', '/application',
array( array(
array( array(
'methods' => \WP_REST_Server::READABLE, 'methods' => \WP_REST_Server::READABLE,
'callback' => array( self::class, 'service_actor' ), 'callback' => array( self::class, 'application_actor' ),
'permission_callback' => '__return_true', 'permission_callback' => '__return_true',
), ),
) )
@ -39,24 +39,24 @@ class Server {
} }
/** /**
* Render Service actor profile * Render Application actor profile
* *
* @return WP_REST_Response * @return WP_REST_Response
*/ */
public static function service_actor() { public static function application_actor() {
$json = new \stdClass(); $json = new \stdClass();
$json->{'@context'} = \Activitypub\get_context(); $json->{'@context'} = \Activitypub\get_context();
$json->id = \get_rest_url( null, 'activitypub/1.0/service' ); $json->id = \get_rest_url( null, 'activitypub/1.0/application' );
$json->type = 'Application'; $json->type = 'Application';
$json->preferredUsername = parse_url( get_site_url(), PHP_URL_HOST ); $json->preferredUsername = parse_url( get_site_url(), PHP_URL_HOST );
$json->name = get_bloginfo( 'name' ); $json->name = get_bloginfo( 'name' );
$json->summary = "ActivityPub service actor"; $json->summary = "WordPress-ActivityPub application actor";
$json->manuallyApprovesFollowers = TRUE; $json->manuallyApprovesFollowers = TRUE;
$json->icon = [ get_site_icon_url() ]; $json->icon = [ get_site_icon_url() ];
$json->publicKey = (object) array( $json->publicKey = (object) array(
'id' => \get_rest_url( null, 'activitypub/1.0/service#main-key' ), 'id' => \get_rest_url( null, 'activitypub/1.0/application#main-key' ),
'owner' => \get_rest_url( null, 'activitypub/1.0/service' ), 'owner' => \get_rest_url( null, 'activitypub/1.0/application' ),
'publicKeyPem' => Signature::get_public_key( -1 ), 'publicKeyPem' => Signature::get_public_key( -1 ),
); );