1
1
Fork 0

Partly reworked, part 2

This commit is contained in:
Michael 2019-12-23 14:30:48 +00:00
parent 9cc2212b4b
commit 2306b949f2

View file

@ -645,7 +645,7 @@ class Probe
$result = self::diaspora($webfinger); $result = self::diaspora($webfinger);
} }
if ((!$result && ($network == "")) || ($network == Protocol::OSTATUS)) { if ((!$result && ($network == "")) || ($network == Protocol::OSTATUS)) {
$result = self::ostatus($webfinger, false); $result = self::ostatus($webfinger);
} }
// if (in_array($network, ['', Protocol::ZOT])) { // if (in_array($network, ['', Protocol::ZOT])) {
// $result = self::zot($webfinger, $result); // $result = self::zot($webfinger, $result);
@ -654,7 +654,7 @@ class Probe
$result = self::pumpio($webfinger, $addr); $result = self::pumpio($webfinger, $addr);
} }
if ((!$result && ($network == "")) || ($network == Protocol::FEED)) { if ((!$result && ($network == "")) || ($network == Protocol::FEED)) {
$result = self::feed($uri, true); $result = self::feed($uri);
} else { } else {
// We overwrite the detected nick with our try if the previois routines hadn't detected it. // We overwrite the detected nick with our try if the previois routines hadn't detected it.
// Additionally it is overwritten when the nickname doesn't make sense (contains spaces). // Additionally it is overwritten when the nickname doesn't make sense (contains spaces).
@ -1294,7 +1294,6 @@ class Probe
private static function diaspora($webfinger) private static function diaspora($webfinger)
{ {
$hcard_url = ""; $hcard_url = "";
$data = []; $data = [];
// The array is reversed to take into account the order of preference for same-rel links // The array is reversed to take into account the order of preference for same-rel links
@ -1345,6 +1344,10 @@ class Probe
// Fetch further information from the hcard // Fetch further information from the hcard
$data = self::pollHcard($hcard_url, $data); $data = self::pollHcard($hcard_url, $data);
if (!$data) {
return false;
}
if (!empty($data["url"]) if (!empty($data["url"])
&& !empty($data["guid"]) && !empty($data["guid"])
&& !empty($data["baseurl"]) && !empty($data["baseurl"])
@ -1361,6 +1364,8 @@ class Probe
// We have to overwrite the detected value for "notify" since Hubzilla doesn't send it // We have to overwrite the detected value for "notify" since Hubzilla doesn't send it
$data["notify"] = $data["baseurl"] . "/receive/users/" . $data["guid"]; $data["notify"] = $data["baseurl"] . "/receive/users/" . $data["guid"];
$data["batch"] = $data["baseurl"] . "/receive/public"; $data["batch"] = $data["baseurl"] . "/receive/public";
} else {
return false;
} }
return $data; return $data;
@ -1419,11 +1424,7 @@ class Probe
$curlResult = Network::curl($pubkey); $curlResult = Network::curl($pubkey);
if ($curlResult->isTimeout()) { if ($curlResult->isTimeout()) {
self::$istimeout = true; self::$istimeout = true;
if ($short) {
return false; return false;
} else {
return $data;
}
} }
$pubkey = $curlResult->getBody(); $pubkey = $curlResult->getBody();
} }
@ -1444,10 +1445,8 @@ class Probe
&& isset($data["url"]) && isset($data["url"])
) { ) {
$data["network"] = Protocol::OSTATUS; $data["network"] = Protocol::OSTATUS;
} elseif ($short) {
return false;
} else { } else {
return $data; return false;
} }
if ($short) { if ($short) {
@ -1458,7 +1457,7 @@ class Probe
$curlResult = Network::curl($data["poll"]); $curlResult = Network::curl($data["poll"]);
if ($curlResult->isTimeout()) { if ($curlResult->isTimeout()) {
self::$istimeout = true; self::$istimeout = true;
return $data; return false;
} }
$feed = $curlResult->getBody(); $feed = $curlResult->getBody();
$dummy1 = null; $dummy1 = null;
@ -1466,7 +1465,7 @@ class Probe
$dummy2 = null; $dummy2 = null;
$feed_data = Feed::import($feed, $dummy1, $dummy2, $dummy3, true); $feed_data = Feed::import($feed, $dummy1, $dummy2, $dummy3, true);
if (!$feed_data) { if (!$feed_data) {
return $data; return false;
} }
if (!empty($feed_data["header"]["author-name"])) { if (!empty($feed_data["header"]["author-name"])) {