From 792212b6554aa5990a761920bf78bc6a35962c04 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 22 Jan 2022 19:42:37 -0700 Subject: [PATCH] Cleanup --- app/Services/WebfingerService.php | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/app/Services/WebfingerService.php b/app/Services/WebfingerService.php index 3615018bc..c7eb9e93f 100644 --- a/app/Services/WebfingerService.php +++ b/app/Services/WebfingerService.php @@ -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); } }