diff --git a/src/Objects/ObjectsService.php b/src/Objects/ObjectsService.php index 52ef17d..436d2c8 100644 --- a/src/Objects/ObjectsService.php +++ b/src/Objects/ObjectsService.php @@ -7,6 +7,7 @@ namespace ActivityPub\Objects; use ActivityPub\Entities\ActivityPubObject; use ActivityPub\Entities\Field; use ActivityPub\Utils\DateTimeProvider; +use ActivityPub\Utils\Util; use Doctrine\ORM\EntityManager; use Doctrine\ORM\QueryBuilder; use GuzzleHttp\Client; @@ -311,13 +312,14 @@ class ObjectsService */ public function dereference( $id ) { - // TOOD pass a $request into here, so that I can sign the request below and so that - // I can check for local objects that should not result in network calls $object = $this->getObject( $id ); if ( $object ) { return $object; } - // TODO sign this request? + if ( Util::isLocalUri( $id ) ) { + return null; + } + // TODO sign this request? Would have to pass in the request object to get the actor to sign with $request = new Request( 'GET', $id, array( 'Accept' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' ) ); diff --git a/src/Utils/Util.php b/src/Utils/Util.php index 118f385..f9479f5 100644 --- a/src/Utils/Util.php +++ b/src/Utils/Util.php @@ -2,6 +2,8 @@ namespace ActivityPub\Utils; +use Symfony\Component\HttpFoundation\Request; + class Util { /** @@ -32,5 +34,11 @@ class Util } return true; } + + public static function isLocalUri( $uri ) + { + $request = Request::createFromGlobals(); + return parse_url( $uri, PHP_URL_HOST ) === $request->getHost(); + } }