]> git.mxchange.org Git - friendica.git/commitdiff
Replace custom WebFinger implementation by Probe::getWebfingerArray in APContact...
authorHypolite Petovan <hypolite@mrpetovan.com>
Thu, 26 Jan 2023 05:03:57 +0000 (00:03 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Fri, 27 Jan 2023 06:24:28 +0000 (01:24 -0500)
- This implementation didn't support separate domains for the address and the final account

src/Model/APContact.php
src/Network/Probe.php

index 09a6cb9e78db781f1ccabac557cd5fbc0747b40c..c72028ef3159b9a430f9f1900e03c12d777340a4 100644 (file)
@@ -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;
                        }
index 7c2760393a94b9aaa2b207603653c9d3557da8ec..12ac8a04f943b8a7faeef08e08a74e6f60df661c 100644 (file)
@@ -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);