]> git.mxchange.org Git - friendica.git/blobdiff - include/Probe.php
Merge pull request #2859 from rabuzarus/0510-update_fullcalendar
[friendica.git] / include / Probe.php
index 7cda542d0b45659545dc2bb19719ff7085b87af8..a245ef250f2e12b001de453a98d6dca410795761 100644 (file)
@@ -118,18 +118,16 @@ class Probe {
         */
 
        public static function webfinger_dfrn($webbie, &$hcard) {
-               if (!strstr($webbie, '@'))
-                       return $webbie;
 
                $profile_link = '';
 
-               $links = self::webfinger($webbie);
+               $links = self::lrdd($webbie);
                logger('webfinger_dfrn: '.$webbie.':'.print_r($links,true), LOGGER_DATA);
                if (count($links)) {
                        foreach ($links as $link) {
                                if ($link['@attributes']['rel'] === NAMESPACE_DFRN)
                                        $profile_link = $link['@attributes']['href'];
-                               if ($link['@attributes']['rel'] === NAMESPACE_OSTATUSSUB)
+                               if (($link['@attributes']['rel'] === NAMESPACE_OSTATUSSUB) AND ($profile_link == ""))
                                        $profile_link = 'stat:'.$link['@attributes']['template'];
                                if ($link['@attributes']['rel'] === 'http://microformats.org/profile/hcard')
                                        $hcard = $link['@attributes']['href'];
@@ -180,6 +178,11 @@ class Probe {
 
                        $path = str_replace('{uri}', urlencode($uri), $link);
                        $webfinger = self::webfinger($path);
+
+                       if (!$webfinger AND (strstr($uri, "@"))) {
+                               $path = str_replace('{uri}', urlencode("acct:".$uri), $link);
+                               $webfinger = self::webfinger($path);
+                       }
                }
 
                if (!is_array($webfinger["links"]))
@@ -310,6 +313,7 @@ class Probe {
                                return array("network" => NETWORK_TWITTER);
 
                        $lrdd = self::xrd($host);
+
                        if (!$lrdd)
                                return self::mail($uri, $uid);
 
@@ -356,6 +360,12 @@ class Probe {
                        $path = str_replace('{uri}', urlencode($addr), $link);
                        $webfinger = self::webfinger($path);
 
+                       // Mastodon needs to have it with "acct:"
+                       if (!$webfinger) {
+                               $path = str_replace('{uri}', urlencode("acct:".$addr), $link);
+                               $webfinger = self::webfinger($path);
+                       }
+
                        // If webfinger wasn't successful then try it with the URL - possibly in the format https://...
                        if (!$webfinger AND ($uri != $addr)) {
                                $path = str_replace('{uri}', urlencode($uri), $link);
@@ -788,6 +798,9 @@ class Probe {
                        isset($data["pubkey"]) AND ($hcard != "")) {
                        $data["network"] = NETWORK_DIASPORA;
 
+                       // The Diaspora handle must always be lowercase
+                       $data["addr"] = strtolower($data["addr"]);
+
                        // We have to overwrite the detected value for "notify" since Hubzilla doesn't send it
                        $data["notify"] = $data["baseurl"]."/receive/users/".$data["guid"];
                        $data["batch"] = $data["baseurl"]."/receive/public";
@@ -812,6 +825,9 @@ class Probe {
                                if (strstr($alias, "@"))
                                        $data["addr"] = str_replace('acct:', '', $alias);
 
+               if (is_string($webfinger["subject"]) AND strstr($webfinger["subject"], "@"))
+                       $data["addr"] = str_replace('acct:', '', $webfinger["subject"]);
+
                $pubkey = "";
                foreach ($webfinger["links"] AS $link) {
                        if (($link["rel"] == "http://webfinger.net/rel/profile-page") AND
@@ -829,7 +845,7 @@ class Probe {
                                                $pubkey = substr($pubkey, strpos($pubkey, ',') + 1);
                                        else
                                                $pubkey = substr($pubkey, 5);
-                               } else
+                               } elseif (normalise_link($pubkey) == 'http://')
                                        $pubkey = fetch_url($pubkey);
 
                                $key = explode(".", $pubkey);