From 8b9faf3179b11624b41facd68c3a3e30c0bc049b Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 16 Mar 2020 22:40:03 -0600 Subject: [PATCH] Update WebfingerService, cache lookup --- app/Services/WebfingerService.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/Services/WebfingerService.php b/app/Services/WebfingerService.php index a50eee19f..1269dd0eb 100644 --- a/app/Services/WebfingerService.php +++ b/app/Services/WebfingerService.php @@ -3,6 +3,7 @@ namespace App\Services; use Cache; +use App\Profile; use Illuminate\Support\Facades\Redis; use App\Util\Webfinger\WebfingerUrl; use Zttp\Zttp; @@ -21,6 +22,12 @@ 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(); + } $url = WebfingerUrl::generateWebfingerUrl($query); if(!Helpers::validateUrl($url)) { return [];