forked from mirror/pixelfed
Update ApiV1Controller, use domainBlock filtering on public/network feeds
This commit is contained in:
parent
6d81214138
commit
21947835f8
|
@ -31,6 +31,7 @@ use App\{
|
||||||
UserSetting,
|
UserSetting,
|
||||||
UserFilter,
|
UserFilter,
|
||||||
};
|
};
|
||||||
|
use App\Models\UserDomainBlock;
|
||||||
use League\Fractal;
|
use League\Fractal;
|
||||||
use App\Transformer\Api\Mastodon\v1\{
|
use App\Transformer\Api\Mastodon\v1\{
|
||||||
AccountTransformer,
|
AccountTransformer,
|
||||||
|
@ -2422,6 +2423,7 @@ class ApiV1Controller extends Controller
|
||||||
$local = $request->has('local');
|
$local = $request->has('local');
|
||||||
$filtered = $user ? UserFilterService::filters($user->profile_id) : [];
|
$filtered = $user ? UserFilterService::filters($user->profile_id) : [];
|
||||||
AccountService::setLastActive($user->id);
|
AccountService::setLastActive($user->id);
|
||||||
|
$domainBlocks = UserFilterService::domainBlocks($user->profile_id);
|
||||||
|
|
||||||
if($remote && config('instance.timeline.network.cached')) {
|
if($remote && config('instance.timeline.network.cached')) {
|
||||||
Cache::remember('api:v1:timelines:network:cache_check', 10368000, function() {
|
Cache::remember('api:v1:timelines:network:cache_check', 10368000, function() {
|
||||||
|
@ -2496,6 +2498,13 @@ class ApiV1Controller extends Controller
|
||||||
->filter(function($s) use($filtered) {
|
->filter(function($s) use($filtered) {
|
||||||
return $s && isset($s['account']) && in_array($s['account']['id'], $filtered) == false;
|
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)
|
->take($limit)
|
||||||
->values();
|
->values();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue