[WIP] Begin implementing collection handling for GetObjectController
This commit is contained in:
parent
cab1f667f4
commit
3320ba45ee
@ -41,7 +41,11 @@ class GetObjectController
|
||||
'Signature realm="ActivityPub",headers="(request-target) host date"'
|
||||
);
|
||||
}
|
||||
// TODO handle collections here
|
||||
if ( $object->hasField( 'type' ) &&
|
||||
( $object['type'] === 'Collection' ||
|
||||
$object['type'] === 'OrderedCollection' ) ) {
|
||||
return $this->pageAndFilterCollection( $request, $object );
|
||||
}
|
||||
return new JsonResponse( $object->asArray() );
|
||||
}
|
||||
|
||||
@ -59,7 +63,7 @@ class GetObjectController
|
||||
in_array( $request->attributes->get( 'actor' ), $audience );
|
||||
}
|
||||
|
||||
public function hasAudience( ActivityPubObject $object )
|
||||
private function hasAudience( ActivityPubObject $object )
|
||||
{
|
||||
$arr = $object->asArray( 0 );
|
||||
return array_key_exists( 'audience', $arr ) ||
|
||||
@ -105,5 +109,17 @@ class GetObjectController
|
||||
}
|
||||
return $audience;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array representation of the $collection
|
||||
*
|
||||
* If the collection's size is greater than 30, return a PagedCollection instead,
|
||||
* and filter all items by the request's permissions
|
||||
*/
|
||||
private function pageAndFilterCollection( Request $request,
|
||||
ActivityPubObject $collection )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -40,7 +40,7 @@ class GetObjectControllerTest extends TestCase
|
||||
'id' => 'https://example.com/objects/2',
|
||||
'type' => 'Note',
|
||||
),
|
||||
'type' => 'Collection',
|
||||
'type' => 'Like',
|
||||
'actor' => array(
|
||||
'id' => 'https://example.com/actor/2',
|
||||
),
|
||||
|
Loading…
Reference in New Issue
Block a user