mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-17 20:11:27 +00:00
Update SearchApiV2Service, add support for Moved accounts
This commit is contained in:
parent
6d565b81fd
commit
d0c376f579
1 changed files with 9 additions and 10 deletions
|
@ -11,7 +11,6 @@ use Illuminate\Support\Str;
|
||||||
use League\Fractal;
|
use League\Fractal;
|
||||||
use League\Fractal\Serializer\ArraySerializer;
|
use League\Fractal\Serializer\ArraySerializer;
|
||||||
|
|
||||||
|
|
||||||
class SearchApiV2Service
|
class SearchApiV2Service
|
||||||
{
|
{
|
||||||
private $query;
|
private $query;
|
||||||
|
@ -119,7 +118,7 @@ class SearchApiV2Service
|
||||||
AccountService::get($res['id']);
|
AccountService::get($res['id']);
|
||||||
})
|
})
|
||||||
->filter(function ($account) {
|
->filter(function ($account) {
|
||||||
return $account && isset($account['id']);
|
return $account && isset($account['id']) && ! isset($account['moved'], $account['moved']['id']);
|
||||||
})
|
})
|
||||||
->values();
|
->values();
|
||||||
|
|
||||||
|
@ -248,7 +247,7 @@ class SearchApiV2Service
|
||||||
|
|
||||||
if ($sid = Status::whereUri($query)->first()) {
|
if ($sid = Status::whereUri($query)->first()) {
|
||||||
$s = StatusService::get($sid->id, false);
|
$s = StatusService::get($sid->id, false);
|
||||||
if (! $s) {
|
if (! $s || isset($s['account']['moved'], $s['account']['moved']['id'])) {
|
||||||
return $default;
|
return $default;
|
||||||
}
|
}
|
||||||
if (in_array($s['visibility'], ['public', 'unlisted'])) {
|
if (in_array($s['visibility'], ['public', 'unlisted'])) {
|
||||||
|
@ -359,7 +358,7 @@ class SearchApiV2Service
|
||||||
->whereUsername($query)
|
->whereUsername($query)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if (! $profile) {
|
if (! $profile || $profile->moved_to_profile_id) {
|
||||||
return [
|
return [
|
||||||
'accounts' => [],
|
'accounts' => [],
|
||||||
'hashtags' => [],
|
'hashtags' => [],
|
||||||
|
@ -367,9 +366,9 @@ class SearchApiV2Service
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$fractal = new Fractal\Manager();
|
$fractal = new Fractal\Manager;
|
||||||
$fractal->setSerializer(new ArraySerializer());
|
$fractal->setSerializer(new ArraySerializer);
|
||||||
$resource = new Fractal\Resource\Item($profile, new AccountTransformer());
|
$resource = new Fractal\Resource\Item($profile, new AccountTransformer);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'accounts' => [$fractal->createData($resource)->toArray()],
|
'accounts' => [$fractal->createData($resource)->toArray()],
|
||||||
|
@ -393,9 +392,9 @@ class SearchApiV2Service
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$fractal = new Fractal\Manager();
|
$fractal = new Fractal\Manager;
|
||||||
$fractal->setSerializer(new ArraySerializer());
|
$fractal->setSerializer(new ArraySerializer);
|
||||||
$resource = new Fractal\Resource\Item($profile, new AccountTransformer());
|
$resource = new Fractal\Resource\Item($profile, new AccountTransformer);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'accounts' => [$fractal->createData($resource)->toArray()],
|
'accounts' => [$fractal->createData($resource)->toArray()],
|
||||||
|
|
Loading…
Reference in a new issue