Don't attempt to dereference local objects via http
This commit is contained in:
parent
35241944cf
commit
e10b111a4b
@ -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"'
|
||||
) );
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user