migrated missing parts

This commit is contained in:
Matthias Pfefferle 2023-06-01 11:50:01 +02:00
parent 112eb51af1
commit d251060624
2 changed files with 4 additions and 7 deletions

View file

@ -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' ) );

View file

@ -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 );