Remove legacy code

This commit is contained in:
Jeremy Dormitzer 2019-01-21 11:10:17 -05:00
parent 2f458c0448
commit d6981b5106
4 changed files with 0 additions and 282 deletions

View File

@ -1,93 +0,0 @@
<?php
namespace ActivityPub\Actors;
use ActivityPub\Crypto\RsaKeypair;
use ActivityPub\Entities\ActivityPubObject;
/**
* Represents an ActivityPub actor object
*
* This class is the main entrypoint for the ActivityPub API, via the
* inbox() and outbox() methods.
*/
class Actor
{
/**
* The ActivityPubObject that represents this actor
*
* @var ActivityPubObject
*/
private $object;
/**
* The actor's inbox
*
* @var Inbox
*/
private $inbox;
/**
* The actor's outbox
*
* @var Outbox
*/
private $outbox;
/**
* The actor's RSA keypair
*
* @var RsaKeypair
*/
private $keypair;
/**
* Constructs a new actor
*
* @param ActivityPubObject $object The ActivityPubObject that represents the actor
* @param RsaKeypair $keypair The actor's RSA keypair
*/
public function __construct( ActivityPubObject $object,
RsaKeypair $keypair )
{
if ( ! $object['inbox'] || ! $object['outbox'] ) {
throw new InvalidArgumentException(
'Attempted to construct an ActivityPubActor without an inbox or outbox'
);
}
$this->object = $object;
$this->keypair = $keypair;
$this->inbox = new Inbox( $this, $object['inbox'] );
$this->outbox = new Outbox( $this, $object['outbox'] );
}
/**
* Returns the actor's inbox
*
* @return Inbox
*/
public function inbox()
{
return $this->inbox;
}
/**
* Returns the actor's outbox
*
* @return Outbox
*/
public function outbox()
{
return $this->outbox;
}
/**
* Returns the actor's keypair
*
* @return RsaKeypair
*/
public function keypair()
{
return $this->keypair;
}
}
?>

View File

@ -1,87 +0,0 @@
<?php
namespace ActivityPub\Actors;
use ActivityPub\Crypto\RsaKeypair;
use ActivityPub\Objects\ObjectService;
use ActivityPub\Utils\Util;
use Doctrine\ORM\EntityManager;
class ActorService
{
/**
* @var ObjectService
*/
private $objectService;
/**
* @var EntityManager
*/
private $entityManager;
public function __construct( ObjectService $objectService, EntityManager entityManager )
{
$this->objectService = $objectService;
$this->entityManager = $entityManager;
}
/**
* Creates a new Actor object
*
* Also creates the actor's collections - inbox, outbox, following,
* followers, and liked - and the actor's public/private keypair.
* The collections will have ids generated by appending /<collection name>
* to the end of the actor's id, e.g. /inbox, /outbox, etc. The public key
* will have its id generated by appending #main-key to the end of the actor's
* id. The private key will be persisted and associated with the actor object.
*
* @param array $fields The actor's fields. The id and type fields are required
* @return Actor The created Actor object
*/
public function createActor( $fields )
{
$requiredFields = array( 'id', 'type' );
if ( ! Util::arrayKeysExist( $fields, $requiredFields ) ) {
throw new InvalidArgumentException( 'Actors require id and type fields' );
}
$actorId = rtrim( $fields['id'], '/' );
// Create keypair
$keypair = RsaKeypair::generate();
$entityManager->persist( $keypair );
$publicKeyField = array(
'id' => "${actorId}#main-key",
'owner' => $actorId,
'publicKeyPem' => $keypair->getPublicKey(),
);
$fields['publicKey'] = $publicKeyField;
// Create collections
// Persist actor ActivityPubObject
}
/**
* Returns the actor identified by $id
*
* @param string $id The actor's id
* @return ActivityPubActor The actor
*/
public function getActor( $id )
{
}
/**
* Deletes the actor identified by $id by replacing it with a Tombstone object
*
* Also deletes the actor's collections - inbox, outbox, following,
* followers, and liked - and the actor's public/private keypair.
* @param string $id The actor's id
* @return ActivityPubObject The Tombstone that the actor was replaced with
*/
public function deleteActor( $id )
{
}
}
?>

View File

@ -1,51 +0,0 @@
<?php
namespace ActivityPub\Actors;
use ActivityPub\Actors\Actor;
use ActivityPub\Entities\ActivityPubObject;
/**
* The Inbox class represents an ActivityPub inbox. It provides methods
* to receive activities in an actor's inbox.
*/
class Inbox
{
/**
* The ActivityPubObject that represents this inbox
*
* @var ActivityPubObject
*/
private $object;
/**
* The actor to which this inbox belongs
*
* @var Actor
*/
private $actor;
/**
* Constructs a new Inbox
*
* @param Actor $actor The actor to which the inbox belongs
* @param ActivityPubObject $object The ActivityPubObject that represents the inbox
*/
public function __construct( Actor $actor, ActivityPubObject $object )
{
$this->actor = $actor;
$this->object = $object;
}
/**
* Receives a new activity to the inbox, verifying the provided signature.
*
* @param ActivityPubObject $activity The received activity
* @param string $signature A valid signature for the activity, signed with
* the the private key of the actor who created it
*/
public function receive( ActivityPubObject $activity, string signature )
{
// TODO
}
}
?>

View File

@ -1,51 +0,0 @@
<?php
namespace ActivityPub\Actors;
use ActivityPub\Actors\Actor;
use ActivityPub\Entities\ActivityPubObject;
/**
* The Outbox class represents an ActivityPub outbox. It provides methods
* to post activities to an actor's outbox, and takes care of signing and
* delivering posted activities.
*/
class Outbox
{
/**
* The ActivityPubObject that represents this outbox
*
* @var ActivityPubObject
*/
private $object;
/**
* The actor to which this outbox belongs
*
* @var Actor
*/
private $actor;
/**
* Constructs a new Outbox
*
* @param Actor $actor The actor to which the outbox belongs
* @param ActivityPubObject $object The ActivityPubObject that represents the outbox
*/
public function __construct( Actor $actor, ActivityPubObject $object )
{
$this->actor = $actor;
$this->object = $object;
}
/**
* Posts a new activity to the outbox, signing and delivering the activity
* to the correct recipients.
*
* @param ActivityPubObject $activity The activity
*/
public function post( ActivityPubObject $activity )
{
// TODO
}
}
?>