gnu-social/plugins/ActivityPub/Util/Response/ActorResponse.php

24 lines
596 B
PHP
Raw Normal View History

<?php
declare(strict_types = 1);
namespace Plugin\ActivityPub\Util\Response;
2021-09-18 11:22:27 +09:00
use App\Entity\Actor;
use Exception;
use Plugin\ActivityPub\Util\Model\EntityToType\GSActorToType;
abstract class ActorResponse
{
/**
* @param int $status The response status code
*
2021-09-18 11:22:27 +09:00
*@throws Exception
*/
2021-09-18 11:22:27 +09:00
public static function handle(Actor $gsactor, int $status = 200): TypeResponse
{
$gsactor->getLocalUser(); // This throws exception if not a local user, which is intended
return new TypeResponse(data: GSActorToType::translate($gsactor), status: $status);
}
}