瀏覽代碼

Update WebfingerService, cache lookup

Daniel Supernault 5 年之前
父節點
當前提交
8b9faf3179
共有 1 個文件被更改,包括 7 次插入0 次删除
  1. 7 0
      app/Services/WebfingerService.php

+ 7 - 0
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 [];