2021-04-02 17:20:02 +00:00
|
|
|
<?php
|
|
|
|
|
2021-06-08 09:52:11 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2021-04-02 17:20:02 +00:00
|
|
|
/**
|
2022-02-19 16:06:11 +00:00
|
|
|
* @copyright 2021 Ad Aures
|
2021-04-02 17:20:02 +00:00
|
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
|
|
* @link https://castopod.org/
|
|
|
|
*/
|
|
|
|
|
2021-08-23 11:05:16 +00:00
|
|
|
namespace Modules\Fediverse\Objects;
|
2021-04-02 17:20:02 +00:00
|
|
|
|
2021-08-23 11:05:16 +00:00
|
|
|
use Modules\Fediverse\Core\ObjectType;
|
|
|
|
use Modules\Fediverse\Entities\Actor;
|
2021-04-02 17:20:02 +00:00
|
|
|
|
|
|
|
class ActorObject extends ObjectType
|
|
|
|
{
|
|
|
|
/**
|
2021-05-14 17:59:35 +00:00
|
|
|
* @var string|string[]
|
2021-04-02 17:20:02 +00:00
|
|
|
*/
|
2021-05-19 16:35:13 +00:00
|
|
|
protected string | array $context = ['https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1'];
|
2021-04-02 17:20:02 +00:00
|
|
|
|
2021-05-18 17:16:36 +00:00
|
|
|
protected string $type = 'Person';
|
2021-05-19 16:35:13 +00:00
|
|
|
|
2021-05-18 17:16:36 +00:00
|
|
|
protected string $name;
|
2021-05-19 16:35:13 +00:00
|
|
|
|
2021-05-18 17:16:36 +00:00
|
|
|
protected string $preferredUsername;
|
2021-05-19 16:35:13 +00:00
|
|
|
|
2021-05-18 17:16:36 +00:00
|
|
|
protected string $summary;
|
2021-05-19 16:35:13 +00:00
|
|
|
|
2021-05-18 17:16:36 +00:00
|
|
|
protected string $inbox;
|
2021-05-19 16:35:13 +00:00
|
|
|
|
2021-05-18 17:16:36 +00:00
|
|
|
protected string $outbox;
|
2021-05-19 16:35:13 +00:00
|
|
|
|
2021-05-18 17:16:36 +00:00
|
|
|
protected string $followers;
|
2021-05-19 16:35:13 +00:00
|
|
|
|
2021-05-18 17:16:36 +00:00
|
|
|
protected string $url;
|
2021-04-02 17:20:02 +00:00
|
|
|
|
2022-01-06 14:26:03 +00:00
|
|
|
protected string $nodeInfo2Url;
|
|
|
|
|
2021-04-02 17:20:02 +00:00
|
|
|
/**
|
2021-05-18 17:16:36 +00:00
|
|
|
* @var array<string, string>
|
2021-04-02 17:20:02 +00:00
|
|
|
*/
|
2021-05-18 17:16:36 +00:00
|
|
|
protected array $image = [];
|
2021-04-02 17:20:02 +00:00
|
|
|
|
|
|
|
/**
|
2021-05-14 17:59:35 +00:00
|
|
|
* @var array<string, string>
|
2021-04-02 17:20:02 +00:00
|
|
|
*/
|
2021-05-18 17:16:36 +00:00
|
|
|
protected array $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-18 17:16:36 +00:00
|
|
|
protected array $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;
|
2022-01-06 14:26:03 +00:00
|
|
|
$this->nodeInfo2Url = url_to('nodeInfo2');
|
2021-04-02 17:20:02 +00:00
|
|
|
|
|
|
|
$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 = [
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'Image',
|
2021-04-14 13:37:11 +00:00
|
|
|
'mediaType' => $actor->cover_image_mimetype,
|
2023-06-12 14:47:38 +00:00
|
|
|
'url' => $actor->cover_image_url,
|
2021-04-14 13:37:11 +00:00
|
|
|
];
|
|
|
|
|
2021-04-02 17:20:02 +00:00
|
|
|
$this->icon = [
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'Image',
|
2021-04-02 17:20:02 +00:00
|
|
|
'mediaType' => $actor->avatar_image_mimetype,
|
2023-06-12 14:47:38 +00:00
|
|
|
'url' => $actor->avatar_image_url,
|
2021-04-02 17:20:02 +00:00
|
|
|
];
|
|
|
|
|
2021-05-12 14:00:25 +00:00
|
|
|
if ($actor->public_key !== null) {
|
|
|
|
$this->publicKey = [
|
2023-06-12 14:47:38 +00:00
|
|
|
'id' => $actor->public_key_id,
|
|
|
|
'owner' => $actor->uri,
|
2021-05-12 14:00:25 +00:00
|
|
|
'publicKeyPem' => $actor->public_key,
|
|
|
|
];
|
|
|
|
}
|
2021-04-02 17:20:02 +00:00
|
|
|
}
|
|
|
|
}
|