2019-12-21 06:15:15 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Util\Site;
|
|
|
|
|
|
|
|
use Cache;
|
|
|
|
use App\{Like, Profile, Status, User};
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
|
|
|
|
class Nodeinfo {
|
|
|
|
|
|
|
|
public static function get()
|
|
|
|
{
|
2021-10-07 06:34:37 +00:00
|
|
|
$res = Cache::remember('api:nodeinfo', 300, function () {
|
|
|
|
$activeHalfYear = Cache::remember('api:nodeinfo:ahy', 172800, function() {
|
|
|
|
return User::select('last_active_at')
|
2021-05-08 03:47:51 +00:00
|
|
|
->where('last_active_at', '>', now()->subMonths(6))
|
2021-10-07 06:34:37 +00:00
|
|
|
->orWhere('created_at', '>', now()->subMonths(6))
|
|
|
|
->count();
|
2021-05-08 03:47:51 +00:00
|
|
|
});
|
2021-10-07 06:34:37 +00:00
|
|
|
|
|
|
|
$activeMonth = Cache::remember('api:nodeinfo:am', 172800, function() {
|
2021-05-08 03:47:51 +00:00
|
|
|
return User::select('last_active_at')
|
|
|
|
->where('last_active_at', '>', now()->subMonths(1))
|
|
|
|
->orWhere('created_at', '>', now()->subMonths(1))
|
|
|
|
->count();
|
|
|
|
});
|
2021-10-07 06:34:37 +00:00
|
|
|
|
|
|
|
$users = Cache::remember('api:nodeinfo:users', 43200, function() {
|
|
|
|
return User::count();
|
|
|
|
});
|
|
|
|
|
|
|
|
$statuses = Cache::remember('api:nodeinfo:statuses', 21600, function() {
|
|
|
|
return Status::whereLocal(true)->count();
|
|
|
|
});
|
|
|
|
|
2022-04-06 04:12:13 +00:00
|
|
|
$features = [ 'features' => \App\Util\Site\Config::get()['features'] ];
|
|
|
|
|
2021-05-08 03:47:51 +00:00
|
|
|
return [
|
|
|
|
'metadata' => [
|
|
|
|
'nodeName' => config_cache('app.name'),
|
|
|
|
'software' => [
|
|
|
|
'homepage' => 'https://pixelfed.org',
|
|
|
|
'repo' => 'https://github.com/pixelfed/pixelfed',
|
|
|
|
],
|
2022-04-06 04:12:13 +00:00
|
|
|
'config' => $features
|
2021-05-08 03:47:51 +00:00
|
|
|
],
|
|
|
|
'protocols' => [
|
|
|
|
'activitypub',
|
|
|
|
],
|
|
|
|
'services' => [
|
|
|
|
'inbound' => [],
|
|
|
|
'outbound' => [],
|
|
|
|
],
|
|
|
|
'software' => [
|
|
|
|
'name' => 'pixelfed',
|
|
|
|
'version' => config('pixelfed.version'),
|
|
|
|
],
|
|
|
|
'usage' => [
|
2023-02-25 06:51:03 +00:00
|
|
|
'localPosts' => (int) $statuses,
|
2021-05-08 03:47:51 +00:00
|
|
|
'localComments' => 0,
|
|
|
|
'users' => [
|
2023-02-25 06:51:03 +00:00
|
|
|
'total' => (int) $users,
|
2021-05-08 03:47:51 +00:00
|
|
|
'activeHalfyear' => (int) $activeHalfYear,
|
|
|
|
'activeMonth' => (int) $activeMonth,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'version' => '2.0',
|
|
|
|
];
|
|
|
|
});
|
2021-05-11 05:23:09 +00:00
|
|
|
$res['openRegistrations'] = (bool) config_cache('pixelfed.open_registration');
|
2021-05-08 03:47:51 +00:00
|
|
|
return $res;
|
2019-12-21 06:15:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function wellKnown()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'links' => [
|
|
|
|
[
|
|
|
|
'href' => config('pixelfed.nodeinfo.url'),
|
|
|
|
'rel' => 'http://nodeinfo.diaspora.software/ns/schema/2.0',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2021-05-08 03:47:51 +00:00
|
|
|
}
|