From 60e053c93671d0e790cde02aa1c51bc011cca17a Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 16 Dec 2023 06:22:56 -0700 Subject: [PATCH] Update ApiV1Controller, update discoverAccountsPopular method --- app/Http/Controllers/Api/ApiV1Controller.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/Api/ApiV1Controller.php b/app/Http/Controllers/Api/ApiV1Controller.php index f5e1202c0..e429a8681 100644 --- a/app/Http/Controllers/Api/ApiV1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Controller.php @@ -3619,25 +3619,31 @@ class ApiV1Controller extends Controller $pid = $request->user()->profile_id; - $ids = Cache::remember('api:v1.1:discover:accounts:popular', 86400, function() { + $ids = Cache::remember('api:v1.1:discover:accounts:popular', 3600, function() { return DB::table('profiles') ->where('is_private', false) ->whereNull('status') ->orderByDesc('profiles.followers_count') - ->limit(20) + ->limit(30) ->get(); }); - + $filters = UserFilterService::filters($pid); $ids = $ids->map(function($profile) { return AccountService::get($profile->id, true); }) ->filter(function($profile) use($pid) { - return $profile && isset($profile['id']); + return $profile && isset($profile['id'], $profile['locked']) && !$profile['locked']; }) ->filter(function($profile) use($pid) { return $profile['id'] != $pid; }) - ->take(6) + ->filter(function($profile) use($pid) { + return !FollowerService::follows($pid, $profile['id'], true); + }) + ->filter(function($profile) use($filters) { + return !in_array($profile['id'], $filters); + }) + ->take(16) ->values(); return $this->json($ids);