Clarify which actor ActivityEvent::actor is

This commit is contained in:
Jeremy Dormitzer 2019-03-30 09:35:17 -04:00
parent fe53b0ca9b
commit c67ddcd760
5 changed files with 12 additions and 12 deletions

View File

@ -48,7 +48,7 @@ class AcceptHandler implements EventSubscriberInterface
if ( $activity['type'] !== 'Accept' ) {
return;
}
$localActor = $event->getActor();
$localActor = $event->getReceivingActor();
$followId = $activity['object'];
if ( is_array( $followId ) && array_key_exists( 'id', $followId ) ) {
$followId = $followId['id'];
@ -118,7 +118,7 @@ class AcceptHandler implements EventSubscriberInterface
if ( is_array( $followObjectId ) && array_key_exists( 'id', $followObjectId ) ) {
$followObjectId = $followObjectId['id'];
}
$localActor = $event->getActor();
$localActor = $event->getReceivingActor();
if ( $followObjectId !== $localActor['id'] ) {
return;
}

View File

@ -17,11 +17,11 @@ class ActivityEvent extends Event
protected $activity;
/**
* The actor posting or receiving the activity
* The actor whose inbox or outbox is receiving the activity
*
* @var ActivityPubObject
*/
protected $actor;
protected $receivingActor;
/**
* The current request
@ -37,11 +37,11 @@ class ActivityEvent extends Event
*/
protected $response;
public function __construct( array $activity, ActivityPubObject $actor,
public function __construct( array $activity, ActivityPubObject $receivingActor,
Request $request )
{
$this->activity = $activity;
$this->actor = $actor;
$this->receivingActor = $receivingActor;
$this->request = $request;
}
@ -59,11 +59,11 @@ class ActivityEvent extends Event
}
/**
* @return ActivityPubObject The actor
* @return ActivityPubObject The actor whose inbox or outbox is receiving the activity
*/
public function getActor()
public function getReceivingActor()
{
return $this->actor;
return $this->receivingActor;
}
/**

View File

@ -43,7 +43,7 @@ class FollowHandler implements EventSubscriberInterface
return;
}
if ( $this->autoAccepts ) {
$localActor = $event->getActor();
$localActor = $event->getReceivingActor();
$objectId = $activity['object'];
if ( is_array( $objectId ) && array_key_exists( 'id', $objectId ) ) {
$objectId = $objectId['id'];

View File

@ -71,7 +71,7 @@ class LikeHandler implements EventSubscriberInterface
return;
}
$object = $activity['object'];
$actor = $event->getActor();
$actor = $event->getReceivingActor();
if ( ! $actor->hasField( 'liked' ) ) {
$actor = $this->addCollectionToObject( $actor, 'liked' );
}

View File

@ -35,7 +35,7 @@ class NonActivityHandler implements EventSubscriberInterface
if ( in_array( $object['type'], self::activityTypes() ) ) {
return;
}
$actor = $event->getActor();
$actor = $event->getReceivingActor();
$create = $this->makeCreate( $object, $actor );
$event->setActivity( $create );
}