mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-25 01:05:36 +00:00
Update search service, fix banned instance edge case
This commit is contained in:
parent
dfcd2e6d2a
commit
74018e9c4e
1 changed files with 13 additions and 2 deletions
|
@ -149,6 +149,9 @@ class SearchApiV2Service
|
|||
->get()
|
||||
->map(function($status) {
|
||||
return StatusService::get($status->id);
|
||||
})
|
||||
->filter(function($status) {
|
||||
return $status && isset($status['account']);
|
||||
});
|
||||
return $results;
|
||||
}
|
||||
|
@ -188,6 +191,7 @@ class SearchApiV2Service
|
|||
|
||||
try {
|
||||
$res = ActivityPubFetchService::get($query);
|
||||
$banned = InstanceService::getBannedDomains();
|
||||
if($res) {
|
||||
$json = json_decode($res, true);
|
||||
|
||||
|
@ -202,10 +206,14 @@ class SearchApiV2Service
|
|||
switch($json['type']) {
|
||||
case 'Note':
|
||||
$obj = Helpers::statusFetch($query);
|
||||
if(!$obj) {
|
||||
if(!$obj || !isset($obj['id'])) {
|
||||
return $default;
|
||||
}
|
||||
$default['statuses'][] = StatusService::get($obj['id']);
|
||||
$note = StatusService::get($obj['id']);
|
||||
if(!$note) {
|
||||
return $default;
|
||||
}
|
||||
$default['statuses'][] = $note;
|
||||
return $default;
|
||||
break;
|
||||
|
||||
|
@ -214,6 +222,9 @@ class SearchApiV2Service
|
|||
if(!$obj) {
|
||||
return $default;
|
||||
}
|
||||
if(in_array($obj['domain'], $banned)) {
|
||||
return $default;
|
||||
}
|
||||
$default['accounts'][] = AccountService::get($obj['id']);
|
||||
return $default;
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue