diff --git a/lib/XRay/Formats/ActivityStreams.php b/lib/XRay/Formats/ActivityStreams.php index a8e4ac3..2d833e1 100644 --- a/lib/XRay/Formats/ActivityStreams.php +++ b/lib/XRay/Formats/ActivityStreams.php @@ -166,8 +166,8 @@ class ActivityStreams extends Format { $repostedData = json_decode($reposted['body'], true); if($repostedData) { $repost = self::parse($repostedData, $as2['object'], $http, $opts); - if($repost) { - $refs[$as2['object']] = $repost; + if($repost && isset($repost['data']) && $repost['data']['type'] != 'unknown') { + $refs[$as2['object']] = $repost['data']; } } } @@ -181,8 +181,8 @@ class ActivityStreams extends Format { $likedData = json_decode($liked['body'], true); if($likedData) { $like = self::parse($likedData, $as2['object'], $http, $opts); - if($like) { - $refs[$as2['object']] = $like; + if($like && isset($like['data']['type']) && $like['data']['type'] != 'unknown') { + $refs[$as2['object']] = $like['data']; } } } diff --git a/tests/ActivityStreamsTest.php b/tests/ActivityStreamsTest.php index deb6b84..260b989 100644 --- a/tests/ActivityStreamsTest.php +++ b/tests/ActivityStreamsTest.php @@ -188,7 +188,7 @@ class ActivityStreamsTest extends PHPUnit_Framework_TestCase { $this->assertEquals('Gargron', $data['data']['author']['nickname']); $this->assertEquals(['http://activitystreams.example/note.json'], $data['data']['repost-of']); $this->assertArrayHasKey('http://activitystreams.example/note.json', $data['data']['refs']); - $this->assertEquals('This is the text content of an ActivityStreams note', $data['data']['refs']['http://activitystreams.example/note.json']['data']['content']['text']); + $this->assertEquals('This is the text content of an ActivityStreams note', $data['data']['refs']['http://activitystreams.example/note.json']['content']['text']); } public function testLike() { @@ -206,7 +206,7 @@ class ActivityStreamsTest extends PHPUnit_Framework_TestCase { $this->assertEquals('Gargron', $data['data']['author']['nickname']); $this->assertEquals(['http://activitystreams.example/note.json'], $data['data']['like-of']); $this->assertArrayHasKey('http://activitystreams.example/note.json', $data['data']['refs']); - $this->assertEquals('This is the text content of an ActivityStreams note', $data['data']['refs']['http://activitystreams.example/note.json']['data']['content']['text']); + $this->assertEquals('This is the text content of an ActivityStreams note', $data['data']['refs']['http://activitystreams.example/note.json']['content']['text']); } public function testNoteWrappedInCreate() {