Browse Source

fix likes and reposts

pull/78/head v1.6.4
Aaron Parecki 3 years ago
parent
commit
707e750429
No known key found for this signature in database GPG Key ID: 276C2817346D6056
2 changed files with 6 additions and 6 deletions
  1. +4
    -4
      lib/XRay/Formats/ActivityStreams.php
  2. +2
    -2
      tests/ActivityStreamsTest.php

+ 4
- 4
lib/XRay/Formats/ActivityStreams.php View File

@ -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'];
}
}
}

+ 2
- 2
tests/ActivityStreamsTest.php View File

@ -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() {

Loading…
Cancel
Save