Update search service, fix banned instance edge case

This commit is contained in:
Daniel Supernault 2022-03-16 22:38:42 -06:00
parent dfcd2e6d2a
commit 74018e9c4e
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -149,6 +149,9 @@ class SearchApiV2Service
->get() ->get()
->map(function($status) { ->map(function($status) {
return StatusService::get($status->id); return StatusService::get($status->id);
})
->filter(function($status) {
return $status && isset($status['account']);
}); });
return $results; return $results;
} }
@ -188,6 +191,7 @@ class SearchApiV2Service
try { try {
$res = ActivityPubFetchService::get($query); $res = ActivityPubFetchService::get($query);
$banned = InstanceService::getBannedDomains();
if($res) { if($res) {
$json = json_decode($res, true); $json = json_decode($res, true);
@ -202,10 +206,14 @@ class SearchApiV2Service
switch($json['type']) { switch($json['type']) {
case 'Note': case 'Note':
$obj = Helpers::statusFetch($query); $obj = Helpers::statusFetch($query);
if(!$obj) { if(!$obj || !isset($obj['id'])) {
return $default; return $default;
} }
$default['statuses'][] = StatusService::get($obj['id']); $note = StatusService::get($obj['id']);
if(!$note) {
return $default;
}
$default['statuses'][] = $note;
return $default; return $default;
break; break;
@ -214,6 +222,9 @@ class SearchApiV2Service
if(!$obj) { if(!$obj) {
return $default; return $default;
} }
if(in_array($obj['domain'], $banned)) {
return $default;
}
$default['accounts'][] = AccountService::get($obj['id']); $default['accounts'][] = AccountService::get($obj['id']);
return $default; return $default;
break; break;