1
0
Fork 1
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:
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()
->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;