]> git.mxchange.org Git - friendica.git/blobdiff - src/Network/Probe.php
Merge pull request #7997 from annando/zot-aliases
[friendica.git] / src / Network / Probe.php
index fdce4269630a0290ea30a71ccbe6673e0240c649..02a755eec6826b1e43ef6b2a10209df918d0b967 100644 (file)
@@ -647,9 +647,9 @@ class Probe
                if ((!$result && ($network == "")) || ($network == Protocol::OSTATUS)) {
                        $result = self::ostatus($webfinger);
                }
-//             if (in_array($network, ['', Protocol::ZOT])) {
-//                     $result = self::zot($webfinger, $result);
-//             }
+               if (in_array($network, ['', Protocol::ZOT])) {
+                       $result = self::zot($webfinger, $result);
+               }
                if ((!$result && ($network == "")) || ($network == Protocol::PUMPIO)) {
                        $result = self::pumpio($webfinger, $addr);
                }
@@ -719,13 +719,23 @@ class Probe
                if (empty($zot_url) && !empty($data['addr']) && !empty(self::$baseurl)) {
                        $condition = ['nurl' => Strings::normaliseLink(self::$baseurl), 'platform' => ['hubzilla']];
                        if (!DBA::exists('gserver', $condition)) {
-                               exit;
+                               return $data;
                        }
                        $zot_url = self::$baseurl . '/.well-known/zot-info?address=' . $data['addr'];
                }
 
-               if (!empty($zot_url)) {
-                       $data = self::pollZot($zot_url, $data);
+               if (empty($zot_url)) {
+                       return $data;
+               }
+
+               $data = self::pollZot($zot_url, $data);
+
+               if (!empty($data['url']) && !empty($webfinger['aliases']) && is_array($webfinger['aliases'])) {
+                       foreach ($webfinger['aliases'] as $alias) {
+                               if (!strstr($alias, '@') && Strings::normaliseLink($alias) != Strings::normaliseLink($data['url'])) {
+                                       $data['alias'] = $alias;
+                               }
+                       }
                }
 
                return $data;
@@ -746,7 +756,7 @@ class Probe
                if (!is_array($json)) {
                        return $data;
                }
-//print_r($json);
+
                if (empty($data['network'])) {
                        if (!empty($json['protocols']) && in_array('zot', $json['protocols'])) {
                                $data['network'] = Protocol::ZOT;
@@ -1324,7 +1334,7 @@ class Probe
                }
 
                if (empty($data["url"]) || empty($hcard_url)) {
-                       return $data;
+                       return false;
                }
 
                if (!empty($webfinger["aliases"]) && is_array($webfinger["aliases"])) {