From 58fd2f4f652e043ebdeb32584a9bf59e18e7ab68 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 15 Aug 2019 23:23:25 -0600 Subject: [PATCH] Update FederationController, fix invalid nodeinfo schema --- app/Http/Controllers/FederationController.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/FederationController.php b/app/Http/Controllers/FederationController.php index bf7ece665..6eba09c74 100644 --- a/app/Http/Controllers/FederationController.php +++ b/app/Http/Controllers/FederationController.php @@ -11,7 +11,8 @@ use App\{ AccountLog, Like, Profile, - Status + Status, + User }; use App\Transformer\ActivityPub\ProfileOutbox; use App\Util\Lexer\Nickname; @@ -73,7 +74,7 @@ class FederationController extends Controller abort_if(!config('federation.nodeinfo.enabled'), 404); $res = Cache::remember('api:nodeinfo', now()->addMinutes(15), function () { - $activeHalfYear = Cache::remember('api:nodeinfo:ahy', now()->addHours(6), function() { + $activeHalfYear = Cache::remember('api:nodeinfo:ahy', now()->addHours(12), function() { $count = collect([]); $likes = Like::select('profile_id')->with('actor')->where('created_at', '>', now()->subMonths(6)->toDateTimeString())->groupBy('profile_id')->get()->filter(function($like) {return $like->actor && $like->actor->domain == null;})->pluck('profile_id')->toArray(); $count = $count->merge($likes); @@ -83,7 +84,7 @@ class FederationController extends Controller $count = $count->merge($profiles); return $count->unique()->count(); }); - $activeMonth = Cache::remember('api:nodeinfo:am', now()->addHours(6), function() { + $activeMonth = Cache::remember('api:nodeinfo:am', now()->addHours(12), function() { $count = collect([]); $likes = Like::select('profile_id')->where('created_at', '>', now()->subMonths(1)->toDateTimeString())->groupBy('profile_id')->get()->filter(function($like) {return $like->actor && $like->actor->domain == null;})->pluck('profile_id')->toArray(); $count = $count->merge($likes); @@ -100,6 +101,7 @@ class FederationController extends Controller 'homepage' => 'https://pixelfed.org', 'repo' => 'https://github.com/pixelfed/pixelfed', ], + 'config' => \App\Util\Site\Config::get() ], 'protocols' => [ 'activitypub', @@ -113,12 +115,12 @@ class FederationController extends Controller 'version' => config('pixelfed.version'), ], 'usage' => [ - 'localPosts' => \App\Status::whereLocal(true)->whereHas('media')->count(), - 'localComments' => \App\Status::whereLocal(true)->whereNotNull('in_reply_to_id')->count(), + 'localPosts' => Status::whereLocal(true)->count(), + 'localComments' => 0, 'users' => [ - 'total' => \App\Profile::whereNull('status')->whereNull('domain')->count(), - 'activeHalfyear' => $activeHalfYear, - 'activeMonth' => $activeMonth, + 'total' => User::count(), + 'activeHalfyear' => (int) $activeHalfYear, + 'activeMonth' => (int) $activeMonth, ], ], 'version' => '2.0',