diff --git a/includes/rest/class-inbox.php b/includes/rest/class-inbox.php index 9a9bdba..9010df8 100644 --- a/includes/rest/class-inbox.php +++ b/includes/rest/class-inbox.php @@ -341,7 +341,7 @@ class Inbox { public static function convert_object_to_comment_data( $object, $user_id ) { $object['user_id'] = $user_id; if ( ! isset( $object['object']['inReplyTo'] ) ) { - return; + return false; } // check if Activity is public or not @@ -356,13 +356,13 @@ class Inbox { // Only handle replies if ( ! isset( $object['object']['inReplyTo'] ) ) { - return; + return false; } $in_reply_to = $object['object']['inReplyTo']; // Comment already exists if ( \Activitypub\object_id_to_comment( $id ) ) { - return; + return false; } $parent_comment = \Activitypub\object_id_to_comment( $in_reply_to ); @@ -376,7 +376,7 @@ class Inbox { $comment_post_id = $parent_comment->comment_post_ID; } if ( ! $comment_post_id ) { - return; + return false; } return array( diff --git a/tests/test-class-inbox.php b/tests/test-class-inbox.php index 9392cfd..4a4e3a7 100644 --- a/tests/test-class-inbox.php +++ b/tests/test-class-inbox.php @@ -28,7 +28,6 @@ class Test_Inbox extends WP_UnitTestCase { } public function test_convert_object_to_comment_data_basic() { - $inbox = new \Activitypub\Rest\Inbox(); $object = array( 'actor' => $this->user_url, 'to' => [ $this->user_url ], @@ -40,13 +39,13 @@ class Test_Inbox extends WP_UnitTestCase { 'content' => 'example', ), ); - $converted = $inbox->convert_object_to_comment_data( $object, 1 ); + $converted = \Activitypub\Rest\Inbox::convert_object_to_comment_data( $object, 1 ); $this->assertGreaterThan( 1, $converted['comment_post_ID'] ); $this->assertEquals( $converted['comment_author'], 'Example User' ); $this->assertEquals( $converted['comment_author_url'], 'http://example.org' ); $this->assertEquals( $converted['comment_content'], 'example' ); - $this->assertEquals( $converted['comment_type'], '' ); + $this->assertEquals( $converted['comment_type'], 'comment' ); $this->assertEquals( $converted['comment_author_email'], '' ); $this->assertEquals( $converted['comment_parent'], 0 ); $this->assertArrayHasKey( 'comment_meta', $converted ); @@ -57,12 +56,11 @@ class Test_Inbox extends WP_UnitTestCase { } public function test_convert_object_to_comment_data_non_public_rejected() { - $inbox = new \Activitypub\Rest\Inbox(); $object = array( 'to' => array( 'https://example.com/profile/test' ), 'cc' => array(), ); - $converted = $inbox->convert_object_to_comment_data( $object, 1 ); + $converted = \Activitypub\Rest\Inbox::convert_object_to_comment_data( $object, 1 ); $this->assertFalse( $converted ); } }