Update ApiV1Controller, use admin filter service

This commit is contained in:
Daniel Supernault 2024-03-07 03:11:36 -07:00
parent 18382e8a1f
commit 94503a1cf9
No known key found for this signature in database
GPG key ID: 23740873EE6F76A1

View file

@ -37,6 +37,7 @@ use App\Models\Conversation;
use App\Notification; use App\Notification;
use App\Profile; use App\Profile;
use App\Services\AccountService; use App\Services\AccountService;
use App\Services\AdminShadowFilterService;
use App\Services\BookmarkService; use App\Services\BookmarkService;
use App\Services\BouncerService; use App\Services\BouncerService;
use App\Services\CollectionService; use App\Services\CollectionService;
@ -2648,7 +2649,7 @@ class ApiV1Controller extends Controller
$domainBlocks = UserFilterService::domainBlocks($user->profile_id); $domainBlocks = UserFilterService::domainBlocks($user->profile_id);
$hideNsfw = config('instance.hide_nsfw_on_public_feeds'); $hideNsfw = config('instance.hide_nsfw_on_public_feeds');
$amin = SnowflakeService::byDate(now()->subDays(config('federation.network_timeline_days_falloff'))); $amin = SnowflakeService::byDate(now()->subDays(config('federation.network_timeline_days_falloff')));
$asf = AdminShadowFilterService::getHideFromPublicFeedsList();
if ($local && $remote) { if ($local && $remote) {
$feed = Status::select( $feed = Status::select(
'id', 'id',
@ -2824,6 +2825,21 @@ class ApiV1Controller extends Controller
return ! in_array($domain, $domainBlocks); return ! in_array($domain, $domainBlocks);
}) })
->filter(function ($s) use ($asf, $user) {
if (! $asf || count($asf) === 0) {
return true;
}
if (in_array($s['account']['id'], $asf)) {
if ($user->profile_id == $s['account']['id']) {
return true;
}
return false;
}
return true;
})
->take($limit) ->take($limit)
->values(); ->values();