. // }}} /** * ActivityPub implementation for GNU social * * @package GNUsocial * @category ActivityPub * @author Diogo Peralta Cordeiro <@diogo.site> * @copyright 2021 Free Software Foundation, Inc http://www.fsf.org * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ namespace Plugin\ActivityPub\Util\Response; use App\Entity\Actor as GSActor; use App\Util\Exception\ClientException; use Plugin\ActivityPub\Util\Model\Actor as ModelActor; use Plugin\ActivityPub\Util\TypeResponse; /** * Provides a response in application/ld+json to GSActors * * @copyright 2021 Free Software Foundation, Inc http://www.fsf.org * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ abstract class ActorResponse { /** * Provides a response in application/ld+json to GSActors * * @param GSActor $gsactor * @param int $status The response status code * @return TypeResponse * @throws ClientException */ public static function handle(GSActor $gsactor, int $status = 200): TypeResponse { if ($gsactor->getIsLocal()) { return new TypeResponse(json: ModelActor::toJson($gsactor), status: $status); } else { throw new ClientException('This is a remote actor, you should request it to its source of authority instead.'); } } }