From 9d31f73bfaa664faa05d7ab9846a4f6bb8a871b2 Mon Sep 17 00:00:00 2001 From: Daniel Supernault <877217+dansup@users.noreply.github.com> Date: Wed, 31 Aug 2022 21:37:43 -0600 Subject: [PATCH] Fix SearchApiV2Service, improve webfinger condition --- app/Services/SearchApiV2Service.php | 3 +-- app/Services/WebfingerService.php | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Services/SearchApiV2Service.php b/app/Services/SearchApiV2Service.php index 575cfe0da..70877f0c6 100644 --- a/app/Services/SearchApiV2Service.php +++ b/app/Services/SearchApiV2Service.php @@ -33,7 +33,6 @@ class SearchApiV2Service $q = urldecode($query->input('q')); if($query->has('resolve') && - $query->resolve == true && ( Str::startsWith($q, 'https://') || Str::substrCount($q, '@') >= 1) ) { @@ -203,7 +202,7 @@ class SearchApiV2Service return $default; } - if(Str::substrCount($query, '@') == 1 && strpos($query, '@') !== 0) { + if(!Str::startsWith($query, 'http') && Str::substrCount($query, '@') == 1 && strpos($query, '@') !== 0) { try { $res = WebfingerService::lookup('@' . $query, $mastodonMode); } catch (\Exception $e) { diff --git a/app/Services/WebfingerService.php b/app/Services/WebfingerService.php index fd5f81d7f..807914664 100644 --- a/app/Services/WebfingerService.php +++ b/app/Services/WebfingerService.php @@ -56,6 +56,9 @@ class WebfingerService ->first(); $profile = Helpers::profileFetch($link); + if(!$profile) { + return; + } return $mastodonMode ? AccountService::getMastodon($profile->id, true) : AccountService::get($profile->id);