updated plugin ActivityPub version 2.6.1

This commit is contained in:
2024-07-19 19:46:05 +00:00
committed by Gitium
parent 19e351ef3b
commit 3b4e169a1e
39 changed files with 718 additions and 143 deletions

View File

@ -123,7 +123,7 @@ class Actors {
$url = str_replace( '{uri}', $resource, $template );
return new WP_REST_Response(
array( 'url' => $url ),
array( 'url' => $url, 'template' => $template ),
200
);
}

View File

@ -29,7 +29,7 @@ class Comment {
public static function register_routes() {
\register_rest_route(
ACTIVITYPUB_REST_NAMESPACE,
'/(users|actors)/(?P<comment_id>\d+)/remote-reply',
'/comments/(?P<comment_id>\d+)/remote-reply',
array(
array(
'methods' => WP_REST_Server::READABLE,
@ -88,7 +88,7 @@ class Comment {
$url = str_replace( '{uri}', $resource, $template );
return new WP_REST_Response(
array( 'url' => $url ),
array( 'url' => $url, 'template' => $template ),
200
);
}

View File

@ -55,10 +55,28 @@ class Webfinger {
*/
\do_action( 'activitypub_rest_webfinger_pre' );
$code = 200;
$resource = $request->get_param( 'resource' );
$response = self::get_profile( $resource );
return new WP_REST_Response( $response, 200 );
if ( \is_wp_error( $response ) ) {
$code = 400;
$error_data = $response->get_error_data();
if ( isset( $error_data['status'] ) ) {
$code = $error_data['status'];
}
}
return new WP_REST_Response(
$response,
$code,
array(
'Access-Control-Allow-Origin' => '*',
'Content-Type' => 'application/jrd+json; charset=' . get_option( 'blog_charset' ),
)
);
}
/**
@ -88,7 +106,7 @@ class Webfinger {
public static function get_profile( $resource ) {
$user = User_Collection::get_by_resource( $resource );
if ( is_wp_error( $user ) ) {
if ( \is_wp_error( $user ) ) {
return $user;
}