From a88283c526a779389efa2b819201a2331de0f2b2 Mon Sep 17 00:00:00 2001 From: winter Date: Mon, 24 Feb 2025 18:29:51 +0000 Subject: implement federation policies and instance info substitution policy --- routes/actor.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'routes/actor.php') diff --git a/routes/actor.php b/routes/actor.php index c228f45..b768413 100644 --- a/routes/actor.php +++ b/routes/actor.php @@ -1,21 +1,26 @@ mount('/actor/:id', function (array $args) { $actor = Actor::find($args['id']); + $instance = Instance::findByRequestHeaders(); if ($actor == null || $actor->deleted) { throw new NotFound("i don't know that actor"); } if (!$actor->isLocal) { throw new NotFound("that actor is not local!"); } + PolicyManager::getInstance()->checkFederationOrThrow($actor, $instance); if (isset($_SERVER['HTTP_ACCEPT']) && str_contains($_SERVER['HTTP_ACCEPT'], 'text/html')) { throw new TemporaryRedirect("/@/$actor->handle"); } @@ -24,6 +29,8 @@ Router::getInstance()->mount('/actor/:id', function (array $args) { Router::getInstance()->mount('/actor/:id/basicFeed', function (array $args) { $actor = Actor::find($args['id']); + $instance = Instance::findByRequestHeaders(); + PolicyManager::getInstance()->checkFederationOrThrow($actor, $instance); $page = +($_GET['page'] ?? 1); $pageSize = 100; $notes = array_filter( @@ -47,6 +54,8 @@ Router::getInstance()->mount('/actor/:id/basicFeed', function (array $args) { Router::getInstance()->mount('/actor/:id/fullFeed', function (array $args) { $actor = Actor::find($args['id']); + $instance = Instance::findByRequestHeaders(); + PolicyManager::getInstance()->checkFederationOrThrow($actor, $instance); $page = +($_GET['page'] ?? 1); $pageSize = 10; $notes = array_filter( -- cgit v1.3