diff options
Diffstat (limited to 'routes/actor.php')
| -rw-r--r-- | routes/actor.php | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/routes/actor.php b/routes/actor.php index 230f342..710adfa 100644 --- a/routes/actor.php +++ b/routes/actor.php @@ -1,24 +1,28 @@ <?php -use WpfTest\HttpReturnStatus\NotFound; +use WpfTest\HttpResponseStatus\NotFound; +use WpfTest\Model\Actor; use WpfTest\Router; -Router::getInstance()->mount('/user/:username', function (array $args) { - if ($args['username'] != 'winter') { - throw new NotFound('i only know about winter'); +Router::getInstance()->mount('/user/:handle', function (array $args) { + $actor = Actor::findLocalByHandle($args['handle']); + if ($actor == null) { + throw new NotFound("i don't know any local user called " . $args['handle']); } - json_response([ // hardcoded much for testing + json_response([ 'type' => 'actor', - 'self' => path_to_uri('/user/winter'), - 'created' => '2024-12-06T19:40:00+00:00', - 'homepage' => path_to_uri('/winter'), - 'handle' => 'winter', - 'displayName' => 'winter!', - 'bio' => 'winter on php', - 'pronouns' => 'it/she', - 'automated' => false, + 'dbgIsLocal' => $actor->isLocal, + 'self' => path_to_uri("/user/$actor->handle"), + 'created' => $actor->created?->format('c'), + 'modified' => $actor->modified?->format('c'), + 'homepage' => path_to_uri("/$actor->handle"), + 'handle' => $actor->handle, + 'displayName' => $actor->displayName, + 'bio' => $actor->bio, + 'pronouns' => $actor->pronouns, + 'automated' => $actor->automated, 'endpoints' => [ - 'basicFeed' => path_to_uri('/user/winter/basicFeed') + 'basicFeed' => path_to_uri("/user/$actor->handle/basicFeed") ] ]); }); |
