From: Hypolite Petovan Date: Thu, 26 Jan 2023 05:03:57 +0000 (-0500) Subject: Replace custom WebFinger implementation by Probe::getWebfingerArray in APContact... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=79dc5c177ea35917fbae4718ec0f56c67b1e2ebc;p=friendica.git Replace custom WebFinger implementation by Probe::getWebfingerArray in APContact::fetchWebfingerData - This implementation didn't support separate domains for the address and the final account --- diff --git a/src/Model/APContact.php b/src/Model/APContact.php index 09a6cb9e78..c72028ef31 100644 --- a/src/Model/APContact.php +++ b/src/Model/APContact.php @@ -71,21 +71,14 @@ class APContact return $data; } - $data = ['addr' => $addr]; - $template = 'https://' . $addr_parts[1] . '/.well-known/webfinger?resource=acct:' . urlencode($addr); - $webfinger = Probe::webfinger(str_replace('{uri}', urlencode($addr), $template), HttpClientAccept::JRD_JSON); - if (empty($webfinger['links'])) { - $template = 'http://' . $addr_parts[1] . '/.well-known/webfinger?resource=acct:' . urlencode($addr); - $webfinger = Probe::webfinger(str_replace('{uri}', urlencode($addr), $template), HttpClientAccept::JRD_JSON); - if (empty($webfinger['links'])) { - return []; - } - $data['baseurl'] = 'http://' . $addr_parts[1]; - } else { - $data['baseurl'] = 'https://' . $addr_parts[1]; + $webfinger = Probe::getWebfingerArray($addr); + if (empty($webfinger['webfinger']['links'])) { + return []; } - foreach ($webfinger['links'] as $link) { + $data['baseurl'] = $webfinger['baseurl']; + + foreach ($webfinger['webfinger']['links'] as $link) { if (empty($link['rel'])) { continue; } diff --git a/src/Network/Probe.php b/src/Network/Probe.php index 7c2760393a..12ac8a04f9 100644 --- a/src/Network/Probe.php +++ b/src/Network/Probe.php @@ -519,7 +519,7 @@ class Probe * @return array Webfinger data * @throws HTTPException\InternalServerErrorException */ - private static function getWebfingerArray(string $uri): array + public static function getWebfingerArray(string $uri): array { $parts = parse_url($uri);