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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
<?php
use Digitigrade\Db;
use Digitigrade\GlobalSettings;
use Digitigrade\Model\Actor;
use Digitigrade\Model\Note;
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();
$db = Db::getInstance()->getPdo();
$localNotes = $db->query(
'select count(*) from note '
. 'left join actor on actor.id=note.author '
. 'where actor.is_local',
PDO::FETCH_COLUMN, 0
)->fetch();
json_response([
'version' => '2.1',
'software' => [
'name' => 'Digitigrade',
'version' => get_version(),
'repository' => 'https://codeberg.org/winter/digitigrade'
],
'protocols' => ['pawpub'],
'services' => [
'inbound' => [],
'outbound' => ['atom1.0', 'rss2.0']
],
'openRegistrations' => false,
'usage' => [
'users' => [
'total' => UserAccount::count()
],
'localPosts' => $localNotes
],
'metadata' => [
'nodeName' => $s->get('instance.name'),
'nodeDescription' => $s->get('instance.description'),
'pawpub' => [
'extensions' => [
Actor::EXTENSION_POKE,
Note::EXTENSION_LINK_PREVIEWS,
Note::EXTENSION_PAGES,
]
]
]
], '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')
]
]);
});
|