2021-04-02 17:20:02 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @copyright 2021 Podlibre
|
|
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
|
|
* @link https://castopod.org/
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace ActivityPub\Objects;
|
|
|
|
|
2021-05-06 14:00:48 +00:00
|
|
|
use ActivityPub\Entities\Actor;
|
2021-04-02 17:20:02 +00:00
|
|
|
use ActivityPub\Core\ObjectType;
|
|
|
|
|
|
|
|
class ActorObject extends ObjectType
|
|
|
|
{
|
|
|
|
/**
|
2021-05-14 17:59:35 +00:00
|
|
|
* @var string|string[]
|
2021-04-02 17:20:02 +00:00
|
|
|
*/
|
|
|
|
protected $context = [
|
|
|
|
'https://www.w3.org/ns/activitystreams',
|
|
|
|
'https://w3id.org/security/v1',
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $type = 'Person';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $name;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $preferredUsername;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $summary;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $inbox;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $outbox;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $followers;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $url;
|
|
|
|
|
|
|
|
/**
|
2021-05-14 17:59:35 +00:00
|
|
|
* @var array<string, string>|null
|
2021-04-02 17:20:02 +00:00
|
|
|
*/
|
|
|
|
protected $image;
|
|
|
|
|
|
|
|
/**
|
2021-05-14 17:59:35 +00:00
|
|
|
* @var array<string, string>
|
2021-04-02 17:20:02 +00:00
|
|
|
*/
|
2021-05-06 14:00:48 +00:00
|
|
|
protected $icon = [];
|
2021-04-02 17:20:02 +00:00
|
|
|
|
|
|
|
/**
|
2021-05-12 14:00:25 +00:00
|
|
|
* @var array<string, string>
|
2021-04-02 17:20:02 +00:00
|
|
|
*/
|
2021-05-12 14:00:25 +00:00
|
|
|
protected $publicKey = [];
|
2021-04-02 17:20:02 +00:00
|
|
|
|
2021-05-06 14:00:48 +00:00
|
|
|
public function __construct(Actor $actor)
|
2021-04-02 17:20:02 +00:00
|
|
|
{
|
|
|
|
$this->id = $actor->uri;
|
|
|
|
|
|
|
|
$this->name = $actor->display_name;
|
|
|
|
$this->preferredUsername = $actor->username;
|
|
|
|
$this->summary = $actor->summary;
|
|
|
|
$this->url = $actor->uri;
|
|
|
|
|
|
|
|
$this->inbox = $actor->inbox_url;
|
|
|
|
$this->outbox = $actor->outbox_url;
|
|
|
|
$this->followers = $actor->followers_url;
|
|
|
|
|
2021-04-14 13:37:11 +00:00
|
|
|
$this->image = [
|
|
|
|
'type' => 'Image',
|
|
|
|
'mediaType' => $actor->cover_image_mimetype,
|
|
|
|
'url' => $actor->cover_image_url,
|
|
|
|
];
|
|
|
|
|
2021-04-02 17:20:02 +00:00
|
|
|
$this->icon = [
|
|
|
|
'type' => 'Image',
|
|
|
|
'mediaType' => $actor->avatar_image_mimetype,
|
|
|
|
'url' => $actor->avatar_image_url,
|
|
|
|
];
|
|
|
|
|
2021-05-12 14:00:25 +00:00
|
|
|
if ($actor->public_key !== null) {
|
|
|
|
$this->publicKey = [
|
|
|
|
'id' => $actor->public_key_id,
|
|
|
|
'owner' => $actor->uri,
|
|
|
|
'publicKeyPem' => $actor->public_key,
|
|
|
|
];
|
|
|
|
}
|
2021-04-02 17:20:02 +00:00
|
|
|
}
|
|
|
|
}
|