forked from mirror/pixelfed
Update web-api popular accounts route to its own method to remove the breaking oauth scope bug
This commit is contained in:
parent
37a82cfb90
commit
a4bc5ce3d0
3 changed files with 49 additions and 2 deletions
|
@ -4066,7 +4066,7 @@ class ApiV1Controller extends Controller
|
|||
|
||||
$pid = $request->user()->profile_id;
|
||||
|
||||
$ids = Cache::remember('api:v1.1:discover:accounts:popular', 3600, function () {
|
||||
$ids = Cache::remember('api:v1.1:discover:accounts:popular', 14400, function () {
|
||||
return DB::table('profiles')
|
||||
->where('is_private', false)
|
||||
->whereNull('status')
|
||||
|
@ -4075,6 +4075,7 @@ class ApiV1Controller extends Controller
|
|||
->get();
|
||||
});
|
||||
$filters = UserFilterService::filters($pid);
|
||||
$asf = AdminShadowFilterService::getHideFromPublicFeedsList();
|
||||
$ids = $ids->map(function ($profile) {
|
||||
return AccountService::get($profile->id, true);
|
||||
})
|
||||
|
@ -4087,6 +4088,9 @@ class ApiV1Controller extends Controller
|
|||
->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);
|
||||
})
|
||||
|
|
|
@ -5,8 +5,11 @@ namespace App\Http\Controllers;
|
|||
use App\Hashtag;
|
||||
use App\Instance;
|
||||
use App\Like;
|
||||
use App\Services\AccountService;
|
||||
use App\Services\AdminShadowFilterService;
|
||||
use App\Services\BookmarkService;
|
||||
use App\Services\ConfigCacheService;
|
||||
use App\Services\FollowerService;
|
||||
use App\Services\HashtagService;
|
||||
use App\Services\LikeService;
|
||||
use App\Services\ReblogService;
|
||||
|
@ -377,4 +380,44 @@ class DiscoverController extends Controller
|
|||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
|
|||
Route::post('discover/admin/features', 'DiscoverController@updateFeatures');
|
||||
});
|
||||
|
||||
Route::get('discover/accounts/popular', 'Api\ApiV1Controller@discoverAccountsPopular');
|
||||
Route::get('discover/accounts/popular', 'DiscoverController@discoverAccountsPopular');
|
||||
Route::post('web/change-language.json', 'SpaController@updateLanguage');
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue