From a81f5859ada2dd66c8954be795951750fd8a1ff2 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Wed, 5 Oct 2016 20:54:26 +0000 Subject: [PATCH] Mastodon is now detected as OStatus network --- include/Probe.php | 17 ++++++++++++++++- include/salmon.php | 3 +-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/include/Probe.php b/include/Probe.php index 44824103b4..d8814036d9 100644 --- a/include/Probe.php +++ b/include/Probe.php @@ -180,6 +180,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 +315,7 @@ class Probe { return array("network" => NETWORK_TWITTER); $lrdd = self::xrd($host); + if (!$lrdd) return self::mail($uri, $uid); @@ -356,6 +362,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); @@ -815,6 +827,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 @@ -832,7 +847,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); diff --git a/include/salmon.php b/include/salmon.php index 8341b902a7..5e9c4fa616 100644 --- a/include/salmon.php +++ b/include/salmon.php @@ -31,8 +31,7 @@ function get_salmon_key($uri,$keyhash) { $ret[$x] = substr($ret[$x],strpos($ret[$x],',')+1); else $ret[$x] = substr($ret[$x],5); - } - else + } elseif (normalise_link($ret[$x]) == 'http://') $ret[$x] = fetch_url($ret[$x]); } }