mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +00:00
Cleanup
This commit is contained in:
parent
127777261a
commit
792212b655
1 changed files with 5 additions and 16 deletions
|
@ -4,14 +4,10 @@ namespace App\Services;
|
|||
|
||||
use Cache;
|
||||
use App\Profile;
|
||||
use Illuminate\Support\Facades\Redis;
|
||||
use App\Util\Webfinger\WebfingerUrl;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Util\ActivityPub\Helpers;
|
||||
use App\Transformer\Api\AccountTransformer;
|
||||
use League\Fractal;
|
||||
use League\Fractal\Serializer\ArraySerializer;
|
||||
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||
use App\Services\AccountService;
|
||||
|
||||
class WebfingerService
|
||||
{
|
||||
|
@ -23,17 +19,14 @@ class WebfingerService
|
|||
protected function run($query)
|
||||
{
|
||||
if($profile = Profile::whereUsername($query)->first()) {
|
||||
$fractal = new Fractal\Manager();
|
||||
$fractal->setSerializer(new ArraySerializer());
|
||||
$resource = new Fractal\Resource\Item($profile, new AccountTransformer());
|
||||
return $fractal->createData($resource)->toArray();
|
||||
return AccountService::get($profile->id);
|
||||
}
|
||||
$url = WebfingerUrl::generateWebfingerUrl($query);
|
||||
if(!Helpers::validateUrl($url)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$res = Http::retry(3, 500)
|
||||
$res = Http::retry(3, 100)
|
||||
->acceptJson()
|
||||
->withHeaders([
|
||||
'User-Agent' => '(Pixelfed/' . config('pixelfed.version') . '; +' . config('app.url') . ')'
|
||||
|
@ -47,7 +40,7 @@ class WebfingerService
|
|||
|
||||
$webfinger = $res->json();
|
||||
if(!isset($webfinger['links']) || !is_array($webfinger['links']) || empty($webfinger['links'])) {
|
||||
return ['nolinks'];
|
||||
return [];
|
||||
}
|
||||
|
||||
$link = collect($webfinger['links'])
|
||||
|
@ -61,10 +54,6 @@ class WebfingerService
|
|||
->first();
|
||||
|
||||
$profile = Helpers::profileFetch($link);
|
||||
$fractal = new Fractal\Manager();
|
||||
$fractal->setSerializer(new ArraySerializer());
|
||||
$resource = new Fractal\Resource\Item($profile, new AccountTransformer());
|
||||
$res = $fractal->createData($resource)->toArray();
|
||||
return $res;
|
||||
return AccountService::get($profile->id);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue