diff --git a/includes/init.php b/includes/init.php index c866234..6e1cd81 100644 --- a/includes/init.php +++ b/includes/init.php @@ -17,6 +17,12 @@ add_action( 'rest_api_init', function() { add_action( 'user_register', function( $user_id ) { $slug = get_the_author_meta( 'user_nicename', $user_id ); \pterotype\actors\create_actor( $slug, 'user' ); + $actor_id = \pterotype\actors\get_actor_id( $slug ); + $keys_created = \pterotype\pgp\get_public_key( $slug ); + if ( ! $keys_created ) { + $keys = \pterotype\pgp\gen_key( $slug ); + \pterotype\pgp\persist_key( $actor_id, $keys['publickey'], $keys['privatekey'] ); + } } ); add_action( 'pterotype_init', function() { diff --git a/includes/server/deliver.php b/includes/server/deliver.php index 467b171..5cb3345 100644 --- a/includes/server/deliver.php +++ b/includes/server/deliver.php @@ -130,7 +130,7 @@ function post_activity_to_inboxes( $actor_id, $activity, $recipients ) { $request->set_method('POST'); $request->set_body( $activity ); $request->add_header( 'Content-Type', 'application/ld+json' ); - $request->add_header( 'Signature', signature_header( $inbox, $actor_id ) ); + $request->add_header( 'Signature', signature_header( $inbox, $actor_id, $date_str ) ); $request->add_header( 'Date', $date_str ); $server = rest_get_server(); $response = $server->dispatch( $request );