[ActivityStreamsTwo] Initial Actor support

Various bug fixes
This commit is contained in:
2021-09-14 17:15:37 +01:00
parent 1f3a6fe6ac
commit 365edbaff0
10 changed files with 217 additions and 34 deletions

View File

@@ -0,0 +1,49 @@
<?php
namespace Plugin\ActivityStreamsTwo\Util\Model\EntityToType;
use App\Core\Router\Router;
use App\Entity\GSActor;
use DateTimeInterface;
use Exception;
use Plugin\ActivityStreamsTwo\Util\Type;
class GSActorToType
{
/**
* @param GSActor $gsactor
*
* @throws Exception
*
* @return Type
*/
public static function translate(GSActor $gsactor)
{
$uri = Router::url('gsactor_view_id', ['id' => $gsactor->getId()], Router::ABSOLUTE_URL);
$attr = [
'@context' => 'https://www.w3.org/ns/activitystreams',
'id' => $uri,
//'inbox' =>
//'outbox' =>
//'following' =>
//'followers' =>
//'liked' =>
//'streams' =>
'preferredUsername' => $gsactor->getNickname(),
//'publicKey' => [
// 'id' => $uri . "#public-key",
// 'owner' => $uri,
// 'publicKeyPem' => $public_key
// ],
'name' => $gsactor->getFullname(),
//'icon' =>
//'location' =>
'published' => $gsactor->getCreated()->format(DateTimeInterface::RFC3339),
'summary' => $gsactor->getBio(),
//'tag' =>
'updated' => $gsactor->getModified()->format(DateTimeInterface::RFC3339),
'url' => Router::url('gsactor_view_nickname', ['nickname' => $gsactor->getNickname()], Router::ABSOLUTE_URL),
];
return Type::create(type: 'Person', attributes: $attr);
}
}