X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=src%2FNetwork%2FProbe.php;h=810885323df40873630a12b839bfa934c82f0a87;hb=797db32992481ea1e6a581f32950bec52209afe4;hp=e9e8478524606fdce36abb76d9db420dc3b7b34e;hpb=1321a52f1575f8f80e5410980e7d3eb1a29d1fa3;p=friendica.git diff --git a/src/Network/Probe.php b/src/Network/Probe.php index e9e8478524..810885323d 100644 --- a/src/Network/Probe.php +++ b/src/Network/Probe.php @@ -1,6 +1,6 @@ getScheme()) { + return $uri->__toString(); } // Remove the URL fragment, since these shouldn't be part of any profile URL - unset($parts['fragment']); - - $URI = Network::unparseURL($parts); + $uri = $uri->withFragment(''); - return $URI; + return $uri->__toString(); } /** @@ -529,15 +528,10 @@ class Probe $path_parts = explode('/', trim($parts['path'] ?? '', '/')); if (!empty($path_parts)) { $nick = ltrim(end($path_parts), '@'); - // When the last part of the URI is numeric then it is most likely an ID and not a nick name - if (!is_numeric($nick)) { - $addr = $nick . '@' . $host; - } else { - $nick = ''; - } + $addr = $nick . '@' . $host; } - $webfinger = self::getWebfinger($parts['scheme'] . '://' . $host . self::WEBFINGER, 'application/jrd+json', $uri, $addr); + $webfinger = self::getWebfinger($parts['scheme'] . '://' . $host . self::WEBFINGER, HttpClient::ACCEPT_JRD_JSON, $uri, $addr); if (empty($webfinger)) { $lrdd = self::hostMeta($host); } @@ -551,7 +545,7 @@ class Probe $addr = $nick . '@' . $host; } - $webfinger = self::getWebfinger($parts['scheme'] . '://' . $host . self::WEBFINGER, 'application/jrd+json', $uri, $addr); + $webfinger = self::getWebfinger($parts['scheme'] . '://' . $host . self::WEBFINGER, HttpClient::ACCEPT_JRD_JSON, $uri, $addr); if (empty($webfinger)) { $lrdd = self::hostMeta($host); } @@ -569,13 +563,13 @@ class Probe $nick = substr($uri, 0, strpos($uri, '@')); $addr = $uri; - $webfinger = self::getWebfinger('https://' . $host . self::WEBFINGER, 'application/jrd+json', $uri, $addr); + $webfinger = self::getWebfinger('https://' . $host . self::WEBFINGER, HttpClient::ACCEPT_JRD_JSON, $uri, $addr); if (self::$istimeout) { return []; } if (empty($webfinger)) { - $webfinger = self::getWebfinger('http://' . $host . self::WEBFINGER, 'application/jrd+json', $uri, $addr); + $webfinger = self::getWebfinger('http://' . $host . self::WEBFINGER, HttpClient::ACCEPT_JRD_JSON, $uri, $addr); if (self::$istimeout) { return []; } @@ -693,22 +687,21 @@ class Probe } $parts = parse_url($uri); - - if (empty($parts['scheme']) || !empty($parts['host']) && strstr($uri, '@')) { - // If the URI starts with "mailto:" then jump directly to the mail detection - if (strpos($uri, 'mailto:') !== false) { - $uri = str_replace('mailto:', '', $uri); - return self::mail($uri, $uid); - } - - if ($network == Protocol::MAIL) { - return self::mail($uri, $uid); - } - } else { + if (empty($parts['scheme']) && empty($parts['host']) && !strstr($parts['path'], '@')) { Logger::info('URI was not detectable', ['uri' => $uri]); return []; } + // If the URI starts with "mailto:" then jump directly to the mail detection + if (strpos($uri, 'mailto:') !== false) { + $uri = str_replace('mailto:', '', $uri); + return self::mail($uri, $uid); + } + + if ($network == Protocol::MAIL) { + return self::mail($uri, $uid); + } + Logger::info('Probing start', ['uri' => $uri]); if (!empty($ap_profile['addr']) && ($ap_profile['addr'] != $uri)) { @@ -2006,7 +1999,7 @@ class Probe /** * Fetch the last date that the contact had posted something (publically) * - * @param string $data probing result + * @param array $data probing result * @return string last activity */ public static function getLastUpdate(array $data)