mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-10 00:34:50 +00:00
Update ApiV1Controller, use domainBlock filtering on public/network feeds
This commit is contained in:
parent
6d81214138
commit
21947835f8
1 changed files with 9 additions and 0 deletions
|
@ -31,6 +31,7 @@ use App\{
|
|||
UserSetting,
|
||||
UserFilter,
|
||||
};
|
||||
use App\Models\UserDomainBlock;
|
||||
use League\Fractal;
|
||||
use App\Transformer\Api\Mastodon\v1\{
|
||||
AccountTransformer,
|
||||
|
@ -2422,6 +2423,7 @@ class ApiV1Controller extends Controller
|
|||
$local = $request->has('local');
|
||||
$filtered = $user ? UserFilterService::filters($user->profile_id) : [];
|
||||
AccountService::setLastActive($user->id);
|
||||
$domainBlocks = UserFilterService::domainBlocks($user->profile_id);
|
||||
|
||||
if($remote && config('instance.timeline.network.cached')) {
|
||||
Cache::remember('api:v1:timelines:network:cache_check', 10368000, function() {
|
||||
|
@ -2496,6 +2498,13 @@ class ApiV1Controller extends Controller
|
|||
->filter(function($s) use($filtered) {
|
||||
return $s && isset($s['account']) && in_array($s['account']['id'], $filtered) == false;
|
||||
})
|
||||
->filter(function($s) use($domainBlocks) {
|
||||
if(!$domainBlocks || !count($domainBlocks)) {
|
||||
return $s;
|
||||
}
|
||||
$domain = strtolower(parse_url($s['url'], PHP_URL_HOST));
|
||||
return !in_array($domain, $domainBlocks);
|
||||
})
|
||||
->take($limit)
|
||||
->values();
|
||||
|
||||
|
|
Loading…
Reference in a new issue