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