1
0
Fork 0
forked from mirror/pixelfed

Update SearchApiV2Service, filter banned instances

This commit is contained in:
Daniel Supernault 2022-03-12 23:15:47 -07:00
parent 4b9b969fc0
commit 281443d7fe
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -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;
} }