diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2019-02-22 23:04:00 -0100 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2019-02-22 23:04:00 -0100 |
commit | 9ac8eb965b930110d0ec42d56988a10adf1e3f96 (patch) | |
tree | 85234dfae2e24b53a42e17e2abb087b53aa085e1 /lib/Model | |
parent | 8a92d5680abfa80302dafb421699ceb0d0aa74fc (diff) |
boost creation
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib/Model')
-rw-r--r-- | lib/Model/ActivityPub/ACore.php | 5 | ||||
-rw-r--r-- | lib/Model/ActivityPub/Object/Announce.php | 2 | ||||
-rw-r--r-- | lib/Model/ActivityPub/Object/Note.php | 6 | ||||
-rw-r--r-- | lib/Model/ActivityPub/Stream.php | 11 | ||||
-rw-r--r-- | lib/Model/LinkedDataSignature.php | 7 |
5 files changed, 16 insertions, 15 deletions
diff --git a/lib/Model/ActivityPub/ACore.php b/lib/Model/ActivityPub/ACore.php index e248a7a1..9db0df3e 100644 --- a/lib/Model/ActivityPub/ACore.php +++ b/lib/Model/ActivityPub/ACore.php @@ -669,7 +669,10 @@ class ACore extends Item implements JsonSerializable { $this->addEntryBool('local', $this->isLocal()); } - return $this->getEntries(); + $result = $this->getEntries(); + $this->cleanArray($result); + + return $result; } } diff --git a/lib/Model/ActivityPub/Object/Announce.php b/lib/Model/ActivityPub/Object/Announce.php index 31076a0c..1b23d518 100644 --- a/lib/Model/ActivityPub/Object/Announce.php +++ b/lib/Model/ActivityPub/Object/Announce.php @@ -64,8 +64,6 @@ class Announce extends Stream implements JsonSerializable { */ public function import(array $data) { parent::import($data); - - $this->setAttributedTo($this->getActorId()); } diff --git a/lib/Model/ActivityPub/Object/Note.php b/lib/Model/ActivityPub/Object/Note.php index 9edb5300..6207e59e 100644 --- a/lib/Model/ActivityPub/Object/Note.php +++ b/lib/Model/ActivityPub/Object/Note.php @@ -107,7 +107,7 @@ class Note extends Stream implements JsonSerializable { public function importFromDatabase(array $data) { parent::importFromDatabase($data); - $this->setHashtags($this->getArray('hashtags', $data, [])); + $this->setHashtags($this->getArray('hashtags', $data, [])); } @@ -117,10 +117,12 @@ class Note extends Stream implements JsonSerializable { public function jsonSerialize(): array { $result = parent::jsonSerialize(); - if ($this->isCompleteDetails()) { + if ($this->isCompleteDetails()) { $result['hashtags'] = $this->getHashtags(); } + $this->cleanArray($result); + return $result; } diff --git a/lib/Model/ActivityPub/Stream.php b/lib/Model/ActivityPub/Stream.php index c24e4fb2..f9cf86f2 100644 --- a/lib/Model/ActivityPub/Stream.php +++ b/lib/Model/ActivityPub/Stream.php @@ -293,13 +293,13 @@ class Stream extends ACore implements JsonSerializable { * @return array */ public function jsonSerialize(): array { - $this->addEntryInt('publishedTime', $this->getPublishedTime()); - $result = array_merge( parent::jsonSerialize(), [ 'content' => $this->getContent(), - 'attributedTo' => $this->getUrlSocial() . $this->getAttributedTo(), + 'attributedTo' => ($this->getAttributedTo() !== '') ? $this->getUrlSocial() + . $this->getAttributedTo( + ) : '', 'inReplyTo' => $this->getInReplyTo(), 'sensitive' => $this->isSensitive(), 'conversation' => $this->getConversation() @@ -310,11 +310,14 @@ class Stream extends ACore implements JsonSerializable { $result = array_merge( $result, [ - 'cache' => $this->getCache() + 'cache' => ($this->gotCache()) ? $this->getCache() : '', + 'publishedTime' => $this->getPublishedTime() ] ); } + $this->cleanArray($result); + return $result; } diff --git a/lib/Model/LinkedDataSignature.php b/lib/Model/LinkedDataSignature.php index abf4406d..00532cef 100644 --- a/lib/Model/LinkedDataSignature.php +++ b/lib/Model/LinkedDataSignature.php @@ -293,12 +293,7 @@ class LinkedDataSignature implements JsonSerializable { */ private function hashedCanonicalize(array $data, bool $removeEmptyValue = false): string { if ($removeEmptyValue) { - $data = array_filter( - $data, - function($v) { - return ($v !== ''); - } - ); + $this->cleanArray($data); } $object = json_decode(json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); |