aboutsummaryrefslogtreecommitdiffhomepage
path: root/routes
diff options
context:
space:
mode:
authorwinter2024-12-07 21:44:42 +0000
committerwinter2024-12-07 21:44:42 +0000
commita84232811dadccf7047424f27340a7f9847bedff (patch)
treea6a0823c8b9485b6a5b60ea7ae854f9511a6ae1e /routes
parente1ad307b531c27ec6bfaf8b4d018991b0d4a78f3 (diff)
many many changes but actors are loaded from db now
Diffstat (limited to 'routes')
-rw-r--r--routes/actor.php32
-rw-r--r--routes/nodeinfo.php10
-rw-r--r--routes/webfinger.php4
3 files changed, 27 insertions, 19 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")
]
]);
});
diff --git a/routes/nodeinfo.php b/routes/nodeinfo.php
index b507849..e85bca1 100644
--- a/routes/nodeinfo.php
+++ b/routes/nodeinfo.php
@@ -34,9 +34,13 @@ Router::getInstance()->mount('/nodeinfo/2.1', function (array $args) {
'metadata' => [
'nodeName' => "winter's pawsome test server",
'nodeDescription' => 'written in php i dunno',
- 'wpfExtensions' => [
- //
- ]
+ 'wpf' => [
+ 'extensions' => [
+ // 'https://whatever.example/ext/meow',
+ ],
+ // 'pushEndpoint' => path_to_uri('/push'),
+ // 'authEndpoint' => path_to_uri('/auth')
+ ],
]
], 'application/json; profile="http://nodeinfo.diaspora.software/ns/schema/2.1#"');
}); \ No newline at end of file
diff --git a/routes/webfinger.php b/routes/webfinger.php
index 5994529..4445cad 100644
--- a/routes/webfinger.php
+++ b/routes/webfinger.php
@@ -1,8 +1,8 @@
<?php
use WpfTest\GlobalConfig;
-use WpfTest\HttpReturnStatus\BadRequest;
-use WpfTest\HttpReturnStatus\NotFound;
+use WpfTest\HttpResponseStatus\BadRequest;
+use WpfTest\HttpResponseStatus\NotFound;
use WpfTest\Router;
Router::getInstance()->mount('/.well-known/webfinger', function (array $args) {