aboutsummaryrefslogtreecommitdiffhomepage
path: root/routes/nodeinfo.php
blob: 1b2b5374fd1c002cbc3ca2dcfa9b6574483758ba (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php

use Digitigrade\GlobalSettings;
use Digitigrade\Model\UserAccount;
use Digitigrade\Router;

Router::getInstance()->mount('/.well-known/nodeinfo', function (array $args) {
    json_response([
        'links' => [
            [
                'rel' => 'http://nodeinfo.diaspora.software/ns/schema/2.1',
                'href' => path_to_uri('/nodeinfo/2.1')
            ]
        ]
    ], 'application/jrd+json');
});

Router::getInstance()->mount('/nodeinfo/2.1', function (array $args) {
    $s = GlobalSettings::getInstance();
    json_response([
        'version' => '2.1',
        'software' => [
            'name' => 'Digitigrade',
            'version' => get_version()
        ],
        'protocols' => ['pawpub'],
        'services' => [
            'inbound' => [],
            'outbound' => []
        ],
        'openRegistrations' => false,
        'usage' => [
            'users' => [
                'total' => UserAccount::count()
            ]
        ],
        'metadata' => [
            'nodeName' => $s->get('instance.name'),
            'nodeDescription' => $s->get('instance.description'),
            'pawpub' => [
                'extensions' => [
                    // 'https://whatever.example/ext/meow',
                ]
            ]
        ]
    ], 'application/json; profile="http://nodeinfo.diaspora.software/ns/schema/2.1#"');
});

Router::getInstance()->mount('/.well-known/pawpub-instance', function (array $args) {
    $s = GlobalSettings::getInstance();
    json_response([
        'name' => $s->get('instance.name'),
        'description' => $s->get('instance.description'),
        'softwareName' => 'Digitigrade',
        'softwareVersion' => get_version(),
        'softwareDescription' => 'An experimental PawPub server',
        'endpoints' => [
            'auth' => path_to_uri('/auth/main'),
            'subscribe' => path_to_uri('/subscribe'),
            'unsubscribe' => path_to_uri('/unsubscribe'),
            'push' => path_to_uri('/push'),
            'simplePush' => path_to_uri('/push/simple')
        ]
    ]);
});