mirror of
https://github.com/ad-aures/castopod.git
synced 2026-04-11 10:46:43 +02:00
feat(nodeinfo2): add .well-known route for nodeinfo2 containing metadata about the castopod instance
This commit is contained in:
parent
5bf7200fb3
commit
88fddc81d7
5 changed files with 154 additions and 0 deletions
53
modules/Fediverse/Controllers/NodeInfo2Controller.php
Normal file
53
modules/Fediverse/Controllers/NodeInfo2Controller.php
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright 2021 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
* @link https://castopod.org/
|
||||
*/
|
||||
|
||||
namespace Modules\Fediverse\Controllers;
|
||||
|
||||
use CodeIgniter\Controller;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
|
||||
class NodeInfo2Controller extends Controller
|
||||
{
|
||||
public function index(): ResponseInterface
|
||||
{
|
||||
$totalUsers = model('ActorModel')
|
||||
->getTotalLocalActors();
|
||||
$totalPosts = model('PostModel')
|
||||
->getTotalLocalPosts();
|
||||
$activeMonth = model('ActorModel')
|
||||
->getActiveLocalActors(1);
|
||||
$activeHalfyear = model('ActorModel')
|
||||
->getActiveLocalActors(6);
|
||||
|
||||
$nodeInfo2 = [
|
||||
'version' => '1.0',
|
||||
'server' => [
|
||||
'baseUrl' => base_url(),
|
||||
'name' => service('settings')
|
||||
->get('App.siteName'),
|
||||
'software' => 'Castopod Host',
|
||||
'version' => CP_VERSION,
|
||||
],
|
||||
'protocols' => ['activitypub'],
|
||||
'openRegistrations' => config('Auth')
|
||||
->allowRegistration,
|
||||
'usage' => [
|
||||
'users' => [
|
||||
'total' => $totalUsers,
|
||||
'activeMonth' => $activeMonth,
|
||||
'activeHalfyear' => $activeHalfyear,
|
||||
],
|
||||
'localPosts' => $totalPosts,
|
||||
],
|
||||
];
|
||||
|
||||
return $this->response->setJSON($nodeInfo2);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue