2020-07-13 11:45:45 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2022-01-02 08:27:47 +01:00
|
|
|
* @copyright Copyright (C) 2010-2022, the Friendica project
|
2020-07-13 11:45:45 +02:00
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Friendica\Module;
|
|
|
|
|
2021-11-21 21:52:36 +01:00
|
|
|
use Friendica\App;
|
2020-07-13 11:45:45 +02:00
|
|
|
use Friendica\BaseModule;
|
2021-11-21 23:37:17 +01:00
|
|
|
use Friendica\Capabilities\ICanCreateResponses;
|
2020-07-13 11:45:45 +02:00
|
|
|
use Friendica\Core\Addon;
|
2021-11-21 21:52:36 +01:00
|
|
|
use Friendica\Core\Config\Capability\IManageConfigValues;
|
|
|
|
use Friendica\Core\L10n;
|
2020-07-13 11:45:45 +02:00
|
|
|
use Friendica\Model\Nodeinfo;
|
2021-11-21 21:52:36 +01:00
|
|
|
use Friendica\Util\Profiler;
|
|
|
|
use Psr\Log\LoggerInterface;
|
2020-07-13 11:45:45 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Version 1.0 of Nodeinfo, a standardized way of exposing metadata about a server running one of the distributed social networks.
|
|
|
|
* @see https://github.com/jhass/nodeinfo/blob/master/PROTOCOL.md
|
|
|
|
*/
|
|
|
|
class NodeInfo110 extends BaseModule
|
|
|
|
{
|
2021-11-21 21:52:36 +01:00
|
|
|
/** @var IManageConfigValues */
|
|
|
|
protected $config;
|
|
|
|
|
|
|
|
public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IManageConfigValues $config, array $server, array $parameters = [])
|
2020-07-13 11:45:45 +02:00
|
|
|
{
|
2021-11-21 21:52:36 +01:00
|
|
|
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
|
|
|
|
|
|
|
$this->config = $config;
|
|
|
|
}
|
2020-07-13 11:45:45 +02:00
|
|
|
|
2021-11-21 21:52:36 +01:00
|
|
|
protected function rawContent(array $request = [])
|
|
|
|
{
|
2020-07-13 11:45:45 +02:00
|
|
|
$nodeinfo = [
|
|
|
|
'version' => '1.0',
|
|
|
|
'software' => [
|
|
|
|
'name' => 'friendica',
|
|
|
|
'version' => FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION,
|
|
|
|
],
|
|
|
|
'protocols' => [
|
|
|
|
'inbound' => [
|
|
|
|
'friendica'
|
|
|
|
],
|
|
|
|
'outbound' => [
|
|
|
|
'friendica'
|
|
|
|
],
|
|
|
|
],
|
2022-07-23 19:21:44 +02:00
|
|
|
'services' => Nodeinfo::getServices(),
|
|
|
|
'usage' => Nodeinfo::getUsage(),
|
2021-11-21 21:52:36 +01:00
|
|
|
'openRegistrations' => intval($this->config->get('config', 'register_policy')) !== Register::CLOSED,
|
2020-07-13 11:45:45 +02:00
|
|
|
'metadata' => [
|
2021-11-21 21:52:36 +01:00
|
|
|
'nodeName' => $this->config->get('config', 'sitename'),
|
2020-07-13 11:45:45 +02:00
|
|
|
],
|
|
|
|
];
|
|
|
|
|
2021-11-21 21:52:36 +01:00
|
|
|
if (!empty($this->config->get('system', 'diaspora_enabled'))) {
|
|
|
|
$nodeinfo['protocols']['inbound'][] = 'diaspora';
|
2020-07-13 11:45:45 +02:00
|
|
|
$nodeinfo['protocols']['outbound'][] = 'diaspora';
|
|
|
|
}
|
|
|
|
|
2021-11-21 21:52:36 +01:00
|
|
|
if (empty($this->config->get('system', 'ostatus_disabled'))) {
|
|
|
|
$nodeinfo['protocols']['inbound'][] = 'gnusocial';
|
2020-07-13 11:45:45 +02:00
|
|
|
$nodeinfo['protocols']['outbound'][] = 'gnusocial';
|
|
|
|
}
|
|
|
|
|
2021-11-21 21:52:36 +01:00
|
|
|
$nodeinfo['metadata']['protocols'] = $nodeinfo['protocols'];
|
2020-07-13 11:45:45 +02:00
|
|
|
$nodeinfo['metadata']['protocols']['outbound'][] = 'atom1.0';
|
2021-11-21 21:52:36 +01:00
|
|
|
$nodeinfo['metadata']['protocols']['inbound'][] = 'atom1.0';
|
|
|
|
$nodeinfo['metadata']['protocols']['inbound'][] = 'rss2.0';
|
2020-07-13 11:45:45 +02:00
|
|
|
|
|
|
|
$nodeinfo['metadata']['services'] = $nodeinfo['services'];
|
|
|
|
|
|
|
|
if (Addon::isEnabled('twitter')) {
|
|
|
|
$nodeinfo['metadata']['services']['inbound'][] = 'twitter';
|
|
|
|
}
|
|
|
|
|
2021-11-21 21:52:36 +01:00
|
|
|
$nodeinfo['metadata']['explicitContent'] = $this->config->get('system', 'explicit_content', false) == true;
|
2020-07-13 11:45:45 +02:00
|
|
|
|
2021-11-21 23:37:17 +01:00
|
|
|
$this->response->setType(ICanCreateResponses::TYPE_JSON);
|
2021-11-21 21:52:36 +01:00
|
|
|
$this->response->addContent(json_encode($nodeinfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
2020-07-13 11:45:45 +02:00
|
|
|
}
|
|
|
|
}
|