aboutsummaryrefslogtreecommitdiffhomepage
path: root/routes
diff options
context:
space:
mode:
authorwinter2024-12-09 21:13:16 +0000
committerwinter2024-12-09 21:13:16 +0000
commit1ab1c4d9c6a28e9929052bd00f15866eb1a5a200 (patch)
tree1396a368e7e05eb3c701d69deb9311d7361dd2ba /routes
parentbda28640d6e066ae338c6f31407df274ed09f026 (diff)
implement webfinger lookups
Diffstat (limited to 'routes')
-rw-r--r--routes/webfinger.php12
1 files changed, 7 insertions, 5 deletions
diff --git a/routes/webfinger.php b/routes/webfinger.php
index 4445cad..db29e73 100644
--- a/routes/webfinger.php
+++ b/routes/webfinger.php
@@ -3,6 +3,7 @@
use WpfTest\GlobalConfig;
use WpfTest\HttpResponseStatus\BadRequest;
use WpfTest\HttpResponseStatus\NotFound;
+use WpfTest\Model\Actor;
use WpfTest\Router;
Router::getInstance()->mount('/.well-known/webfinger', function (array $args) {
@@ -18,15 +19,16 @@ Router::getInstance()->mount('/.well-known/webfinger', function (array $args) {
if ($remotePart != GlobalConfig::getInstance()->getCanonicalHost()) {
throw new NotFound('i only know about local accounts');
}
- if ($localPart != 'winter') {
- throw new NotFound('i only know about winter!!!');
+ $actor = Actor::findLocalByHandle($localPart);
+ if ($actor == null) {
+ throw new NotFound('no local actor found with that name!');
}
json_response([
- 'subject' => "acct:$localPart@$remotePart",
+ 'subject' => "acct:$actor->handle@$remotePart",
'links' => [
[
- 'rel' => 'urn:example:wpf:actor',
- 'href' => path_to_uri('/user/winter'),
+ 'rel' => Actor::REL_URI,
+ 'href' => path_to_uri("/user/$actor->handle"),
'type' => 'application/json'
]
]