Return a Response from the activity event pipeline
This commit is contained in:
parent
d5d882c9be
commit
a36e44df58
@ -4,6 +4,7 @@ namespace ActivityPub\Activities;
|
||||
use ActivityPub\Entities\ActivityPubObject;
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class ActivityEvent extends Event
|
||||
{
|
||||
@ -28,6 +29,13 @@ class ActivityEvent extends Event
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* The response
|
||||
*
|
||||
* @var Response
|
||||
*/
|
||||
protected $response;
|
||||
|
||||
public function __construct( array $activity, ActivityPubObject $actor,
|
||||
Request $request )
|
||||
{
|
||||
@ -64,5 +72,18 @@ class ActivityEvent extends Event
|
||||
{
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Response The response
|
||||
*/
|
||||
public function getResponse()
|
||||
{
|
||||
return $this->response;
|
||||
}
|
||||
|
||||
public function setResponse( Response $response )
|
||||
{
|
||||
$this->response = $response;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -68,7 +68,7 @@ class PostController
|
||||
$actorWithInbox = $inboxField->getObject();
|
||||
$event = new InboxActivityEvent( $activity, $actorWithInbox, $request );
|
||||
$this->eventDispatcher->dispatch( InboxActivityEvent::NAME, $event );
|
||||
return;
|
||||
return $event->getResponse();
|
||||
}
|
||||
$outboxField = $object->getReferencingField( 'outbox' );
|
||||
if ( $outboxField ) {
|
||||
@ -84,14 +84,13 @@ class PostController
|
||||
}
|
||||
$event = new OutboxActivityEvent( $activity, $actorWithOutbox, $request );
|
||||
$this->eventDispatcher->dispatch( OutboxActivityEvent::NAME, $event );
|
||||
return;
|
||||
return $event->getResponse();
|
||||
}
|
||||
throw new MethodNotAllowedHttpException( array( Request::METHOD_GET ) );
|
||||
}
|
||||
|
||||
private function getActivityActor( array $activity )
|
||||
{
|
||||
xdebug_break();
|
||||
$actor = $activity['actor'];
|
||||
if ( is_array( $actor ) && array_key_exists( 'id', $actor ) ) {
|
||||
return $this->objectsService->dereference( $actor['id'] );
|
||||
|
Loading…
Reference in New Issue
Block a user