|
@@ -5,8 +5,11 @@ namespace App\Http\Controllers;
|
|
use App\Hashtag;
|
|
use App\Hashtag;
|
|
use App\Instance;
|
|
use App\Instance;
|
|
use App\Like;
|
|
use App\Like;
|
|
|
|
+use App\Services\AccountService;
|
|
|
|
+use App\Services\AdminShadowFilterService;
|
|
use App\Services\BookmarkService;
|
|
use App\Services\BookmarkService;
|
|
use App\Services\ConfigCacheService;
|
|
use App\Services\ConfigCacheService;
|
|
|
|
+use App\Services\FollowerService;
|
|
use App\Services\HashtagService;
|
|
use App\Services\HashtagService;
|
|
use App\Services\LikeService;
|
|
use App\Services\LikeService;
|
|
use App\Services\ReblogService;
|
|
use App\Services\ReblogService;
|
|
@@ -377,4 +380,44 @@ class DiscoverController extends Controller
|
|
|
|
|
|
return $res;
|
|
return $res;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public function discoverAccountsPopular(Request $request)
|
|
|
|
+ {
|
|
|
|
+ abort_if(! $request->user(), 403);
|
|
|
|
+
|
|
|
|
+ $pid = $request->user()->profile_id;
|
|
|
|
+
|
|
|
|
+ $ids = Cache::remember('api:v1.1:discover:accounts:popular', 14400, function () {
|
|
|
|
+ return DB::table('profiles')
|
|
|
|
+ ->where('is_private', false)
|
|
|
|
+ ->whereNull('status')
|
|
|
|
+ ->orderByDesc('profiles.followers_count')
|
|
|
|
+ ->limit(30)
|
|
|
|
+ ->get();
|
|
|
|
+ });
|
|
|
|
+ $filters = UserFilterService::filters($pid);
|
|
|
|
+ $asf = AdminShadowFilterService::getHideFromPublicFeedsList();
|
|
|
|
+ $ids = $ids->map(function ($profile) {
|
|
|
|
+ return AccountService::get($profile->id, true);
|
|
|
|
+ })
|
|
|
|
+ ->filter(function ($profile) {
|
|
|
|
+ return $profile && isset($profile['id'], $profile['locked']) && ! $profile['locked'];
|
|
|
|
+ })
|
|
|
|
+ ->filter(function ($profile) use ($pid) {
|
|
|
|
+ return $profile['id'] != $pid;
|
|
|
|
+ })
|
|
|
|
+ ->filter(function ($profile) use ($pid) {
|
|
|
|
+ return ! FollowerService::follows($pid, $profile['id'], true);
|
|
|
|
+ })
|
|
|
|
+ ->filter(function ($profile) use ($asf) {
|
|
|
|
+ return ! in_array($profile['id'], $asf);
|
|
|
|
+ })
|
|
|
|
+ ->filter(function ($profile) use ($filters) {
|
|
|
|
+ return ! in_array($profile['id'], $filters);
|
|
|
|
+ })
|
|
|
|
+ ->take(16)
|
|
|
|
+ ->values();
|
|
|
|
+
|
|
|
|
+ return response()->json($ids, 200, [], JSON_UNESCAPED_SLASHES);
|
|
|
|
+ }
|
|
}
|
|
}
|