aboutsummaryrefslogtreecommitdiffhomepage
path: root/routes/actor.php
blob: 710adfaa47684b6e8937ea259bc2b89c221622d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php

use WpfTest\HttpResponseStatus\NotFound;
use WpfTest\Model\Actor;
use WpfTest\Router;

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([
        'type' => 'actor',
        '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/$actor->handle/basicFeed")
        ]
    ]);
});

Router::getInstance()->mount('/user/:username/basicFeed', function (array $args) {
    if ($args['username'] != 'winter') {
        throw new NotFound('i only know about winter');
    }
    json_response([
        'page' => 1,
        'totalPages' => 1,
        'nextPage' => null,
        'previousPage' => null,
        'items' => [
            path_to_uri('/post/1')
        ]
    ]);
});