diff --git a/includes/class-http.php b/includes/class-http.php index 58551a4..240e5ea 100644 --- a/includes/class-http.php +++ b/includes/class-http.php @@ -2,7 +2,7 @@ namespace Activitypub; use WP_Error; -use Activitypub\Model\User; +use Activitypub\User_Factory; /** * ActivityPub HTTP Class @@ -63,7 +63,7 @@ class Http { */ public static function get( $url ) { $date = \gmdate( 'D, d M Y H:i:s T' ); - $signature = Signature::generate_signature( User::APPLICATION_USER_ID, 'get', $url, $date ); + $signature = Signature::generate_signature( User_Factory::APPLICATION_USER_ID, 'get', $url, $date ); $wp_version = \get_bloginfo( 'version' ); $user_agent = \apply_filters( 'http_headers_useragent', 'WordPress/' . $wp_version . '; ' . \get_bloginfo( 'url' ) ); diff --git a/includes/class-signature.php b/includes/class-signature.php index a91ea0e..c1ccbdf 100644 --- a/includes/class-signature.php +++ b/includes/class-signature.php @@ -136,11 +136,8 @@ class Signature { \openssl_sign( $signed_string, $signature, $key, \OPENSSL_ALGO_SHA256 ); $signature = \base64_encode( $signature ); // phpcs:ignore - if ( User::APPLICATION_USER_ID === $user_id ) { - $key_id = \get_rest_url( null, 'activitypub/1.0/application#main-key' ); - } else { - $key_id = \get_author_posts_url( $user_id ) . '#main-key'; - } + $user = User_Factory::get_by_id( $user_id ); + $key_id = $user->get_url() . '#main-key'; if ( ! empty( $digest ) ) { return \sprintf( 'keyId="%s",algorithm="rsa-sha256",headers="(request-target) host date digest",signature="%s"', $key_id, $signature );