X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FNodeInfo.php;h=99ae26b381536f1fd8960a0c1bd200365dc33814;hb=09de4a5b47439542d5e73d5452e1d30da26c3ae6;hp=deec94d93ffba7f787156625ea44acb61ce833e9;hpb=20b725f07bb9784a85f93ad97c00d817a8c66fc9;p=friendica.git diff --git a/src/Module/NodeInfo.php b/src/Module/NodeInfo.php index deec94d93f..99ae26b381 100644 --- a/src/Module/NodeInfo.php +++ b/src/Module/NodeInfo.php @@ -2,10 +2,10 @@ namespace Friendica\Module; -use Friendica\App; use Friendica\BaseModule; use Friendica\Core\Addon; -use Friendica\Core\System; +use Friendica\DI; +use stdClass; /** * Standardized way of exposing metadata about a server running one of the distributed social networks. @@ -15,12 +15,10 @@ class NodeInfo extends BaseModule { public static function rawContent(array $parameters = []) { - $app = self::getApp(); - if ($parameters['version'] == '1.0') { - self::printNodeInfo1($app); + self::printNodeInfo1(); } elseif ($parameters['version'] == '2.0') { - self::printNodeInfo2($app); + self::printNodeInfo2(); } else { throw new \Friendica\Network\HTTPException\NotFoundException(); } @@ -29,24 +27,22 @@ class NodeInfo extends BaseModule /** * Return the supported services * - * @param App $app - * - * @return array with supported services + * @return Object with supported services */ - private static function getUsage(App $app) + private static function getUsage() { - $config = $app->getConfig(); + $config = DI::config(); - $usage = []; + $usage = new stdClass(); if (!empty($config->get('system', 'nodeinfo'))) { - $usage['users'] = [ + $usage->users = [ 'total' => intval($config->get('nodeinfo', 'total_users')), 'activeHalfyear' => intval($config->get('nodeinfo', 'active_users_halfyear')), 'activeMonth' => intval($config->get('nodeinfo', 'active_users_monthly')) ]; - $usage['localPosts'] = intval($config->get('nodeinfo', 'local_posts')); - $usage['localComments'] = intval($config->get('nodeinfo', 'local_comments')); + $usage->localPosts = intval($config->get('nodeinfo', 'local_posts')); + $usage->localComments = intval($config->get('nodeinfo', 'local_comments')); } return $usage; @@ -55,11 +51,9 @@ class NodeInfo extends BaseModule /** * Return the supported services * - * @param App $app - * * @return array with supported services */ - private static function getServices(App $app) + private static function getServices() { $services = [ 'inbound' => [], @@ -116,12 +110,10 @@ class NodeInfo extends BaseModule /** * Print the nodeinfo version 1 - * - * @param App $app */ - private static function printNodeInfo1(App $app) + private static function printNodeInfo1() { - $config = $app->getConfig(); + $config = DI::config(); $nodeinfo = [ 'version' => '1.0', @@ -131,10 +123,10 @@ class NodeInfo extends BaseModule ], 'protocols' => [ 'inbound' => [ - 'friendica', 'activitypub' + 'friendica' ], 'outbound' => [ - 'friendica', 'activitypub' + 'friendica' ], ], 'services' => [], @@ -155,9 +147,9 @@ class NodeInfo extends BaseModule $nodeinfo['protocols']['outbound'][] = 'gnusocial'; } - $nodeinfo['usage'] = self::getUsage($app); + $nodeinfo['usage'] = self::getUsage(); - $nodeinfo['services'] = self::getServices($app); + $nodeinfo['services'] = self::getServices(); $nodeinfo['metadata']['protocols'] = $nodeinfo['protocols']; $nodeinfo['metadata']['protocols']['outbound'][] = 'atom1.0'; @@ -179,12 +171,10 @@ class NodeInfo extends BaseModule /** * Print the nodeinfo version 2 - * - * @param App $app */ - private static function printNodeInfo2(App $app) + private static function printNodeInfo2() { - $config = $app->getConfig(); + $config = DI::config(); $imap = (function_exists('imap_open') && !$config->get('system', 'imap_disabled') && !$config->get('system', 'dfrn_only')); @@ -211,9 +201,9 @@ class NodeInfo extends BaseModule $nodeinfo['protocols'][] = 'ostatus'; } - $nodeinfo['usage'] = self::getUsage($app); + $nodeinfo['usage'] = self::getUsage(); - $nodeinfo['services'] = self::getServices($app); + $nodeinfo['services'] = self::getServices(); if (Addon::isEnabled('twitter')) { $nodeinfo['services']['inbound'][] = 'twitter';