]> git.mxchange.org Git - friendica.git/blob - src/Module/NodeInfo110.php
Merge pull request #10913 from MrPetovan/bug/10903-profile-edit
[friendica.git] / src / Module / NodeInfo110.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2021, the Friendica project
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Affero General Public License for more details.
16  *
17  * You should have received a copy of the GNU Affero General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  *
20  */
21
22 namespace Friendica\Module;
23
24 use Friendica\BaseModule;
25 use Friendica\Core\Addon;
26 use Friendica\Core\System;
27 use Friendica\DI;
28 use Friendica\Model\Nodeinfo;
29
30 /**
31  * Version 1.0 of Nodeinfo, a standardized way of exposing metadata about a server running one of the distributed social networks.
32  * @see https://github.com/jhass/nodeinfo/blob/master/PROTOCOL.md
33  */
34 class NodeInfo110 extends BaseModule
35 {
36         public static function rawContent(array $parameters = [])
37         {
38                 $config = DI::config();
39
40                 $nodeinfo = [
41                         'version'           => '1.0',
42                         'software'          => [
43                                 'name'    => 'friendica',
44                                 'version' => FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION,
45                         ],
46                         'protocols'         => [
47                                 'inbound'  => [
48                                         'friendica'
49                                 ],
50                                 'outbound' => [
51                                         'friendica'
52                                 ],
53                         ],
54                         'services'          => [],
55                         'usage'             => [],
56                         'openRegistrations' => intval($config->get('config', 'register_policy')) !== Register::CLOSED,
57                         'metadata'          => [
58                                 'nodeName' => $config->get('config', 'sitename'),
59                         ],
60                 ];
61
62                 if (!empty($config->get('system', 'diaspora_enabled'))) {
63                         $nodeinfo['protocols']['inbound'][] = 'diaspora';
64                         $nodeinfo['protocols']['outbound'][] = 'diaspora';
65                 }
66
67                 if (empty($config->get('system', 'ostatus_disabled'))) {
68                         $nodeinfo['protocols']['inbound'][] = 'gnusocial';
69                         $nodeinfo['protocols']['outbound'][] = 'gnusocial';
70                 }
71
72                 $nodeinfo['usage'] = Nodeinfo::getUsage();
73
74                 $nodeinfo['services'] = Nodeinfo::getServices();
75
76                 $nodeinfo['metadata']['protocols'] = $nodeinfo['protocols'];
77                 $nodeinfo['metadata']['protocols']['outbound'][] = 'atom1.0';
78                 $nodeinfo['metadata']['protocols']['inbound'][] = 'atom1.0';
79                 $nodeinfo['metadata']['protocols']['inbound'][] = 'rss2.0';
80
81                 $nodeinfo['metadata']['services'] = $nodeinfo['services'];
82
83                 if (Addon::isEnabled('twitter')) {
84                         $nodeinfo['metadata']['services']['inbound'][] = 'twitter';
85                 }
86
87                 $nodeinfo['metadata']['explicitContent'] = $config->get('system', 'explicit_content', false) == true;
88
89                 System::jsonExit($nodeinfo, 'application/json; charset=utf-8', JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
90         }
91 }