diff --git a/src/Module/NodeInfo.php b/src/Module/NodeInfo.php index a4bc9be2b4..deec94d93f 100644 --- a/src/Module/NodeInfo.php +++ b/src/Module/NodeInfo.php @@ -17,12 +17,7 @@ class NodeInfo extends BaseModule { $app = self::getApp(); - // @TODO: Replace with parameter from router - // if the first argument is ".well-known", print the well-known text - if (($app->argc > 1) && ($app->argv[0] == '.well-known')) { - self::printWellKnown($app); - // otherwise print the nodeinfo - } elseif ($parameters['version'] == '1.0') { + if ($parameters['version'] == '1.0') { self::printNodeInfo1($app); } elseif ($parameters['version'] == '2.0') { self::printNodeInfo2($app); @@ -31,29 +26,6 @@ class NodeInfo extends BaseModule } } - /** - * Prints the well-known nodeinfo redirect - * - * @param App $app - * - * @throws \Friendica\Network\HTTPException\NotFoundException - */ - private static function printWellKnown(App $app) - { - $nodeinfo = [ - 'links' => [ - ['rel' => 'http://nodeinfo.diaspora.software/ns/schema/1.0', - 'href' => $app->getBaseURL() . '/nodeinfo/1.0'], - ['rel' => 'http://nodeinfo.diaspora.software/ns/schema/2.0', - 'href' => $app->getBaseURL() . '/nodeinfo/2.0'], - ] - ]; - - header('Content-type: application/json; charset=utf-8'); - echo json_encode($nodeinfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); - exit; - } - /** * Return the supported services * diff --git a/src/Module/WellKnown/NodeInfo.php b/src/Module/WellKnown/NodeInfo.php new file mode 100644 index 0000000000..7d87252edd --- /dev/null +++ b/src/Module/WellKnown/NodeInfo.php @@ -0,0 +1,43 @@ + [ + ['rel' => 'http://nodeinfo.diaspora.software/ns/schema/1.0', + 'href' => $app->getBaseURL() . '/nodeinfo/1.0'], + ['rel' => 'http://nodeinfo.diaspora.software/ns/schema/2.0', + 'href' => $app->getBaseURL() . '/nodeinfo/2.0'], + ] + ]; + + header('Content-type: application/json; charset=utf-8'); + echo json_encode($nodeinfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); + exit; + } +} diff --git a/static/routes.config.php b/static/routes.config.php index bc98fd5952..f5b44aec22 100644 --- a/static/routes.config.php +++ b/static/routes.config.php @@ -17,7 +17,7 @@ return [ '/.well-known' => [ '/host-meta' => [Module\WellKnown\HostMeta::class, [R::GET]], - '/nodeinfo' => [Module\NodeInfo::class, [R::GET]], + '/nodeinfo' => [Module\WellKnown\NodeInfo::class, [R::GET]], '/webfinger' => [Module\Xrd::class, [R::GET]], '/x-social-relay' => [Module\WellKnown\XSocialRelay::class, [R::GET]], ],