1
0
Fork 0
forked from mirror/pixelfed

Update WebfingerService, cache lookup

This commit is contained in:
Daniel Supernault 2020-03-16 22:40:03 -06:00
parent 6df36a8a7c
commit 8b9faf3179
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -3,6 +3,7 @@
namespace App\Services; namespace App\Services;
use Cache; use Cache;
use App\Profile;
use Illuminate\Support\Facades\Redis; use Illuminate\Support\Facades\Redis;
use App\Util\Webfinger\WebfingerUrl; use App\Util\Webfinger\WebfingerUrl;
use Zttp\Zttp; use Zttp\Zttp;
@ -21,6 +22,12 @@ class WebfingerService
protected function run($query) 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); $url = WebfingerUrl::generateWebfingerUrl($query);
if(!Helpers::validateUrl($url)) { if(!Helpers::validateUrl($url)) {
return []; return [];