Fix missing id

This commit is contained in:
Alex Kirk 2022-12-09 18:44:46 +01:00
parent 483e0a85b2
commit 0925405430
2 changed files with 8 additions and 4 deletions

View file

@ -53,8 +53,8 @@ class Activity {
} }
$this->cc = array( \get_rest_url( null, '/activitypub/1.0/users/' . intval( $post->get_post_author() ) . '/followers' ) ); $this->cc = array( \get_rest_url( null, '/activitypub/1.0/users/' . intval( $post->get_post_author() ) . '/followers' ) );
if ( isset( $object['attributedTo'] ) ) { if ( isset( $this->object['attributedTo'] ) ) {
$this->actor = $object['attributedTo']; $this->actor = $this->object['attributedTo'];
} }
foreach ( $post->get_tags() as $tag ) { foreach ( $post->get_tags() as $tag ) {
@ -65,8 +65,8 @@ class Activity {
$type = \strtolower( $this->type ); $type = \strtolower( $this->type );
if ( isset( $object['id'] ) ) { if ( isset( $this->object['id'] ) ) {
$this->id = add_query_arg( 'activity', $type, $object['id'] ); $this->id = add_query_arg( 'activity', $type, $this->object['id'] );
} }
} }

View file

@ -34,6 +34,7 @@ class Test_Activitypub_Activity_Dispatcher extends ActivityPub_TestCase_Cache_HT
$all_args = $pre_http_request->get_args(); $all_args = $pre_http_request->get_args();
$first_call_args = array_shift( $all_args ); $first_call_args = array_shift( $all_args );
$this->assertEquals( 'https://example.com/author/jon/inbox', $first_call_args[2] ); $this->assertEquals( 'https://example.com/author/jon/inbox', $first_call_args[2] );
$second_call_args = array_shift( $all_args ); $second_call_args = array_shift( $all_args );
$this->assertEquals( 'https://example.org/users/username/inbox', $second_call_args[2] ); $this->assertEquals( 'https://example.org/users/username/inbox', $second_call_args[2] );
@ -73,6 +74,9 @@ class Test_Activitypub_Activity_Dispatcher extends ActivityPub_TestCase_Cache_HT
$first_call_args = $all_args[0]; $first_call_args = $all_args[0];
$this->assertEquals( 'https://example.com/alex/inbox', $first_call_args[2] ); $this->assertEquals( 'https://example.com/alex/inbox', $first_call_args[2] );
$body = json_decode( $first_call_args[1]['body'], true );
$this->assertArrayHasKey( 'id', $body );
remove_all_filters( 'activitypub_from_post_object' ); remove_all_filters( 'activitypub_from_post_object' );
remove_filter( 'pre_http_request', array( $pre_http_request, 'filter' ), 10 ); remove_filter( 'pre_http_request', array( $pre_http_request, 'filter' ), 10 );
} }