forked from mirror/pixelfed
Update SearchApiV2Service, filter banned instances
This commit is contained in:
parent
4b9b969fc0
commit
281443d7fe
1 changed files with 9 additions and 1 deletions
|
@ -85,6 +85,7 @@ class SearchApiV2Service
|
||||||
$limit = $this->query->input('limit') ?? 20;
|
$limit = $this->query->input('limit') ?? 20;
|
||||||
$offset = $this->query->input('offset') ?? 0;
|
$offset = $this->query->input('offset') ?? 0;
|
||||||
$query = '%' . $this->query->input('q') . '%';
|
$query = '%' . $this->query->input('q') . '%';
|
||||||
|
$banned = InstanceService::getBannedDomains();
|
||||||
$results = Profile::select('profiles.*', 'followers.profile_id', 'followers.created_at')
|
$results = Profile::select('profiles.*', 'followers.profile_id', 'followers.created_at')
|
||||||
->whereNull('status')
|
->whereNull('status')
|
||||||
->leftJoin('followers', function($join) use($user) {
|
->leftJoin('followers', function($join) use($user) {
|
||||||
|
@ -97,9 +98,16 @@ class SearchApiV2Service
|
||||||
->offset($offset)
|
->offset($offset)
|
||||||
->limit($limit)
|
->limit($limit)
|
||||||
->get()
|
->get()
|
||||||
|
->filter(function($profile) use ($banned) {
|
||||||
|
return in_array($profile->domain, $banned) == false;
|
||||||
|
})
|
||||||
->map(function($res) {
|
->map(function($res) {
|
||||||
return AccountService::get($res['id']);
|
return AccountService::get($res['id']);
|
||||||
});
|
})
|
||||||
|
->filter(function($account) {
|
||||||
|
return $account && isset($account['id']);
|
||||||
|
})
|
||||||
|
->values();
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue