diff --git a/includes/model/class-activity.php b/includes/model/class-activity.php index 1bdf660..f865d6d 100644 --- a/includes/model/class-activity.php +++ b/includes/model/class-activity.php @@ -53,8 +53,8 @@ class Activity { } $this->cc = array( \get_rest_url( null, '/activitypub/1.0/users/' . intval( $post->get_post_author() ) . '/followers' ) ); - if ( isset( $object['attributedTo'] ) ) { - $this->actor = $object['attributedTo']; + if ( isset( $this->object['attributedTo'] ) ) { + $this->actor = $this->object['attributedTo']; } foreach ( $post->get_tags() as $tag ) { @@ -65,8 +65,8 @@ class Activity { $type = \strtolower( $this->type ); - if ( isset( $object['id'] ) ) { - $this->id = add_query_arg( 'activity', $type, $object['id'] ); + if ( isset( $this->object['id'] ) ) { + $this->id = add_query_arg( 'activity', $type, $this->object['id'] ); } } diff --git a/tests/test-class-activitypub-activity-dispatcher.php b/tests/test-class-activitypub-activity-dispatcher.php index d34a24e..6693ba1 100644 --- a/tests/test-class-activitypub-activity-dispatcher.php +++ b/tests/test-class-activitypub-activity-dispatcher.php @@ -34,6 +34,7 @@ class Test_Activitypub_Activity_Dispatcher extends ActivityPub_TestCase_Cache_HT $all_args = $pre_http_request->get_args(); $first_call_args = array_shift( $all_args ); $this->assertEquals( 'https://example.com/author/jon/inbox', $first_call_args[2] ); + $second_call_args = array_shift( $all_args ); $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]; $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_filter( 'pre_http_request', array( $pre_http_request, 'filter' ), 10 ); }