diff --git a/lib/Controller/LocalController.php b/lib/Controller/LocalController.php index d3adb361..bd0bae2a 100644 --- a/lib/Controller/LocalController.php +++ b/lib/Controller/LocalController.php @@ -325,11 +325,11 @@ class LocalController extends Controller { public function postUnlike(string $postId): DataResponse { try { $this->initViewer(true); - $announce = $this->likeService->delete($this->viewer, $postId, $token); + $like = $this->likeService->delete($this->viewer, $postId, $token); return $this->success( [ - 'like' => $announce, + 'like' => $like, 'token' => $token ] ); @@ -728,7 +728,7 @@ class LocalController extends Controller { public function globalActorAvatar(string $id): Response { try { $actor = $this->cacheActorService->getFromId($id); - if ($actor->gotIcon()) { + if ($actor->hasIcon()) { $avatar = $actor->getIcon(); $mime = ''; $document = $this->documentService->getFromCache($avatar->getId(), $mime); diff --git a/lib/Db/CacheActorsRequest.php b/lib/Db/CacheActorsRequest.php index 3867d7bd..416fe1c8 100644 --- a/lib/Db/CacheActorsRequest.php +++ b/lib/Db/CacheActorsRequest.php @@ -102,7 +102,7 @@ class CacheActorsRequest extends CacheActorsRequestBuilder { } catch (Exception $e) { } - if ($actor->gotIcon()) { + if ($actor->hasIcon()) { $iconId = $actor->getIcon() ->getId(); } else { @@ -160,7 +160,7 @@ class CacheActorsRequest extends CacheActorsRequestBuilder { } catch (Exception $e) { } - if ($actor->gotIcon()) { + if ($actor->hasIcon()) { $iconId = $actor->getIcon() ->getId(); } else { diff --git a/lib/Model/ActivityPub/ACore.php b/lib/Model/ActivityPub/ACore.php index 471968f7..d4ee7870 100644 --- a/lib/Model/ActivityPub/ACore.php +++ b/lib/Model/ActivityPub/ACore.php @@ -171,6 +171,18 @@ class ACore extends Item implements JsonSerializable { return $this; } + /** + * @return string + */ + public function getObjectId(): string { + if ($this->hasObject()) { + return $this->getObject() + ->getId(); + } + + return parent::getObjectId(); + } + /** * @param bool $filter - will remove general url like Public @@ -191,7 +203,7 @@ class ACore extends Item implements JsonSerializable { /** * @return bool */ - public function gotIcon(): bool { + public function hasIcon(): bool { if ($this->icon === null) { return false; } @@ -306,7 +318,7 @@ class ACore extends Item implements JsonSerializable { $origin = $this->getRoot() ->getOrigin(); - if ($origin === $host) { + if ($origin === $host && $host !== '') { return; } @@ -684,7 +696,7 @@ class ACore extends Item implements JsonSerializable { } // TODO - moving the $this->icon to Model/Person ? - if ($this->gotIcon()) { + if ($this->hasIcon()) { $this->addEntryItem('icon', $this->getIcon()); } diff --git a/lib/Service/ActorService.php b/lib/Service/ActorService.php index 78b6620c..429ebf88 100644 --- a/lib/Service/ActorService.php +++ b/lib/Service/ActorService.php @@ -131,7 +131,7 @@ class ActorService { * @param Person $actor */ private function cacheDocumentIfNeeded(Person $actor) { - if ($actor->gotIcon()) { + if ($actor->hasIcon()) { $icon = $actor->getIcon(); try { $cache = $this->cacheDocumentsRequest->getByUrl($icon->getUrl());