mirror of
https://github.com/friendica/friendica
synced 2025-04-20 06:30:10 +00:00
Module classes splitted
This commit is contained in:
parent
96486305da
commit
27deb4d188
6 changed files with 371 additions and 324 deletions
92
src/Module/NodeInfo110.php
Normal file
92
src/Module/NodeInfo110.php
Normal file
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2020, Friendica
|
||||
*
|
||||
* @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;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Nodeinfo;
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
public static function rawContent(array $parameters = [])
|
||||
{
|
||||
$config = DI::config();
|
||||
|
||||
$nodeinfo = [
|
||||
'version' => '1.0',
|
||||
'software' => [
|
||||
'name' => 'friendica',
|
||||
'version' => FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION,
|
||||
],
|
||||
'protocols' => [
|
||||
'inbound' => [
|
||||
'friendica'
|
||||
],
|
||||
'outbound' => [
|
||||
'friendica'
|
||||
],
|
||||
],
|
||||
'services' => [],
|
||||
'usage' => [],
|
||||
'openRegistrations' => intval($config->get('config', 'register_policy')) !== Register::CLOSED,
|
||||
'metadata' => [
|
||||
'nodeName' => $config->get('config', 'sitename'),
|
||||
],
|
||||
];
|
||||
|
||||
if (!empty($config->get('system', 'diaspora_enabled'))) {
|
||||
$nodeinfo['protocols']['inbound'][] = 'diaspora';
|
||||
$nodeinfo['protocols']['outbound'][] = 'diaspora';
|
||||
}
|
||||
|
||||
if (empty($config->get('system', 'ostatus_disabled'))) {
|
||||
$nodeinfo['protocols']['inbound'][] = 'gnusocial';
|
||||
$nodeinfo['protocols']['outbound'][] = 'gnusocial';
|
||||
}
|
||||
|
||||
$nodeinfo['usage'] = Nodeinfo::getUsage();
|
||||
|
||||
$nodeinfo['services'] = Nodeinfo::getServices();
|
||||
|
||||
$nodeinfo['metadata']['protocols'] = $nodeinfo['protocols'];
|
||||
$nodeinfo['metadata']['protocols']['outbound'][] = 'atom1.0';
|
||||
$nodeinfo['metadata']['protocols']['inbound'][] = 'atom1.0';
|
||||
$nodeinfo['metadata']['protocols']['inbound'][] = 'rss2.0';
|
||||
|
||||
$nodeinfo['metadata']['services'] = $nodeinfo['services'];
|
||||
|
||||
if (Addon::isEnabled('twitter')) {
|
||||
$nodeinfo['metadata']['services']['inbound'][] = 'twitter';
|
||||
}
|
||||
|
||||
$nodeinfo['metadata']['explicitContent'] = $config->get('system', 'explicit_content', false) == true;
|
||||
|
||||
header('Content-type: application/json; charset=utf-8');
|
||||
echo json_encode($nodeinfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
|
||||
exit;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue