mirror of
https://github.com/friendica/friendica
synced 2025-04-24 00:30:11 +00:00
Inherit ApiResponse
from Response
This commit is contained in:
parent
561aba18e3
commit
537b74f307
46 changed files with 326 additions and 277 deletions
|
@ -21,11 +21,15 @@
|
|||
|
||||
namespace Friendica\Module;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Capabilities\IRespondToRequests;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Model\Nodeinfo;
|
||||
use Friendica\Util\Profiler;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Version 2.0 of Nodeinfo, a standardized way of exposing metadata about a server running one of the distributed social networks.
|
||||
|
@ -33,30 +37,38 @@ use Friendica\Model\Nodeinfo;
|
|||
*/
|
||||
class NodeInfo120 extends BaseModule
|
||||
{
|
||||
/** @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 = [])
|
||||
{
|
||||
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
$config = DI::config();
|
||||
|
||||
$nodeinfo = [
|
||||
'version' => '2.0',
|
||||
'software' => [
|
||||
'version' => '2.0',
|
||||
'software' => [
|
||||
'name' => 'friendica',
|
||||
'version' => FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION,
|
||||
],
|
||||
'protocols' => ['dfrn', 'activitypub'],
|
||||
'services' => [],
|
||||
'usage' => [],
|
||||
'openRegistrations' => intval($config->get('config', 'register_policy')) !== Register::CLOSED,
|
||||
'openRegistrations' => intval($this->config->get('config', 'register_policy')) !== Register::CLOSED,
|
||||
'metadata' => [
|
||||
'nodeName' => $config->get('config', 'sitename'),
|
||||
'nodeName' => $this->config->get('config', 'sitename'),
|
||||
],
|
||||
];
|
||||
|
||||
if (!empty($config->get('system', 'diaspora_enabled'))) {
|
||||
if (!empty($this->config->get('system', 'diaspora_enabled'))) {
|
||||
$nodeinfo['protocols'][] = 'diaspora';
|
||||
}
|
||||
|
||||
if (empty($config->get('system', 'ostatus_disabled'))) {
|
||||
if (empty($this->config->get('system', 'ostatus_disabled'))) {
|
||||
$nodeinfo['protocols'][] = 'ostatus';
|
||||
}
|
||||
|
||||
|
@ -72,12 +84,13 @@ class NodeInfo120 extends BaseModule
|
|||
$nodeinfo['services']['inbound'][] = 'rss2.0';
|
||||
$nodeinfo['services']['outbound'][] = 'atom1.0';
|
||||
|
||||
if (function_exists('imap_open') && !$config->get('system', 'imap_disabled')) {
|
||||
if (function_exists('imap_open') && !$this->config->get('system', 'imap_disabled')) {
|
||||
$nodeinfo['services']['inbound'][] = 'imap';
|
||||
}
|
||||
|
||||
$nodeinfo['metadata']['explicitContent'] = $config->get('system', 'explicit_content', false) == true;
|
||||
$nodeinfo['metadata']['explicitContent'] = $this->config->get('system', 'explicit_content', false) == true;
|
||||
|
||||
System::jsonExit($nodeinfo, 'application/json; charset=utf-8', JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
|
||||
$this->response->setType(IRespondToRequests::TYPE_JSON, 'application/json; charset=utf-8');
|
||||
$this->response->addContent(json_encode($nodeinfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue