
- fixed rewrites to properly support @username/outbox, username/outbox, users/username/outbox, ... - initial support for sending follow to e.g. mastodon (code commented out in api.php) - database migration for follows table and fedusers table - save retrieved fedusers in cache and db - depend more on configs externaldomain, less on server_name - properly implemented following-logic in dio - made postForuUser static in newContent and inbox - provide rsaprivate for signing reuests -> actPub-Servers - change contenttype depending on use-case - changed user json-template to have loop-back between user-template and webfinger (mastodon f.e. needs this)
79 lines
2.1 KiB
PHP
79 lines
2.1 KiB
PHP
<?php
|
|
/**
|
|
* SPDX-FileCopyrightText: 2024 Sascha Nitsch (grumpydeveloper) https://contentnation.net/@grumpydevelop
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
*
|
|
* @author Sascha Nitsch (grumpydeveloper)
|
|
**/
|
|
|
|
namespace Federator\Api\WellKnown;
|
|
|
|
class NodeInfo
|
|
{
|
|
/**
|
|
* parent instance
|
|
*
|
|
* @var \Federator\Api\WellKnown $wellKnown
|
|
*/
|
|
private $wellKnown;
|
|
|
|
/**
|
|
* main instance
|
|
*
|
|
* @var \Federator\Main $main
|
|
*/
|
|
private $main;
|
|
|
|
/**
|
|
* constructor
|
|
*
|
|
* @param \Federator\Api\WellKnown $wellKnown parent instance
|
|
* @param \Federator\Main $main main instance
|
|
* @return void
|
|
*/
|
|
public function __construct($wellKnown, $main)
|
|
{
|
|
$this->wellKnown = $wellKnown;
|
|
$this->main = $main;
|
|
}
|
|
|
|
/**
|
|
* handle nodeinfo request
|
|
*
|
|
* @param string[] $paths path of us
|
|
* @return bool true on success
|
|
*/
|
|
public function exec($paths)
|
|
{
|
|
$config = $this->main->getConfig();
|
|
$domain = $config['generic']['externaldomain'];
|
|
$data = [
|
|
'fqdn' => $domain
|
|
];
|
|
$template = null;
|
|
if (sizeof($paths) == 2 && $paths[0] === '.well-known' && $paths[1] === 'nodeinfo') {
|
|
$template = 'nodeinfo.json';
|
|
} else {
|
|
if ($paths[0] !== 'nodeinfo') {
|
|
throw new \Federator\Exceptions\FileNotFound();
|
|
}
|
|
}
|
|
if ($template === null) {
|
|
switch ($paths[1]) {
|
|
case '2.1':
|
|
$template = 'nodeinfo2.1.json';
|
|
break;
|
|
default:
|
|
$template = 'nodeinfo2.0.json';
|
|
}
|
|
$stats = \Federator\DIO\Stats::getStats($this->main);
|
|
echo "fetch usercount via connector\n";
|
|
$data['usercount'] = $stats->userCount;
|
|
$data['postcount'] = $stats->postCount;
|
|
$data['commentcount'] = $stats->commentCount;
|
|
}
|
|
$tpl = $this->main->renderTemplate($template, $data);
|
|
$this->wellKnown->setResponse($tpl);
|
|
return true;
|
|
}
|
|
}
|