mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-25 15:55:22 +00:00
Update ApiV1Controller, apply user domain blocks filtering to hashtag timelines
This commit is contained in:
parent
fcbcd7ec73
commit
89b8e87477
1 changed files with 7 additions and 4 deletions
|
@ -3285,6 +3285,7 @@ class ApiV1Controller extends Controller
|
||||||
$limit = $request->input('limit', 20);
|
$limit = $request->input('limit', 20);
|
||||||
$onlyMedia = $request->input('only_media', true);
|
$onlyMedia = $request->input('only_media', true);
|
||||||
$pe = $request->has(self::PF_API_ENTITY_KEY);
|
$pe = $request->has(self::PF_API_ENTITY_KEY);
|
||||||
|
$pid = $request->user()->profile_id;
|
||||||
|
|
||||||
if($min || $max) {
|
if($min || $max) {
|
||||||
$minMax = SnowflakeService::byDate(now()->subMonths(6));
|
$minMax = SnowflakeService::byDate(now()->subMonths(6));
|
||||||
|
@ -3296,7 +3297,8 @@ class ApiV1Controller extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$filters = UserFilterService::filters($request->user()->profile_id);
|
$filters = UserFilterService::filters($pid);
|
||||||
|
$domainBlocks = UserFilterService::domainBlocks($pid);
|
||||||
|
|
||||||
if(!$min && !$max) {
|
if(!$min && !$max) {
|
||||||
$id = 1;
|
$id = 1;
|
||||||
|
@ -3322,10 +3324,11 @@ class ApiV1Controller extends Controller
|
||||||
if($onlyMedia && !isset($i['media_attachments']) || !count($i['media_attachments'])) {
|
if($onlyMedia && !isset($i['media_attachments']) || !count($i['media_attachments'])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return $i && isset($i['account']);
|
return $i && isset($i['account'], $i['url']);
|
||||||
})
|
})
|
||||||
->filter(function($i) use($filters) {
|
->filter(function($i) use($filters, $domainBlocks) {
|
||||||
return !in_array($i['account']['id'], $filters);
|
$domain = strtolower(parse_url($i['url'], PHP_URL_HOST));
|
||||||
|
return !in_array($i['account']['id'], $filters) && !in_array($domain, $domainBlocks);
|
||||||
})
|
})
|
||||||
->values()
|
->values()
|
||||||
->toArray();
|
->toArray();
|
||||||
|
|
Loading…
Reference in a new issue