X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FNetwork%2FProbe.php;h=2c84ddb85a8312f42a6e3f5d5723051e56045161;hb=3020b0fdc4f4ccdfc1deccc23b8748066a7c9979;hp=258bb6c628cd3271b45f54fc6eb6d8656217e870;hpb=6a549d4cfb523eb1bbfc1a08c41e38fee8b2a40d;p=friendica.git diff --git a/src/Network/Probe.php b/src/Network/Probe.php index 258bb6c628..2c84ddb85a 100644 --- a/src/Network/Probe.php +++ b/src/Network/Probe.php @@ -19,6 +19,7 @@ use Friendica\Model\Contact; use Friendica\Model\Profile; use Friendica\Protocol\Email; use Friendica\Protocol\Feed; +use Friendica\Protocol\ActivityPub; use Friendica\Util\Crypto; use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; @@ -328,7 +329,17 @@ class Probe $uid = local_user(); } - $data = self::detect($uri, $network, $uid); + if ($network != Protocol::ACTIVITYPUB) { + $data = self::detect($uri, $network, $uid); + } else { + $data = null; + } + + $ap_profile = ActivityPub::probeProfile($uri); + + if (!empty($ap_profile) && (defaults($data, 'network', '') != Protocol::DFRN)) { + $data = $ap_profile; + } if (!isset($data["url"])) { $data["url"] = $uri; @@ -934,9 +945,10 @@ class Probe $prof_data = []; - if (empty($data["addr"])) { + if (empty($data["addr"]) || empty($data["nick"])) { $probe_data = self::uri($profile_link); - $data["addr"] = $probe_data["addr"]; + $data["addr"] = defaults($data, "addr", $probe_data["addr"]); + $data["nick"] = defaults($data, "nick", $probe_data["nick"]); } $prof_data["addr"] = $data["addr"]; @@ -966,23 +978,23 @@ class Probe $hcard_url = ""; $data = []; foreach ($webfinger["links"] as $link) { - if (($link["rel"] == NAMESPACE_DFRN) && ($link["href"] != "")) { + if (($link["rel"] == NAMESPACE_DFRN) && !empty($link["href"])) { $data["network"] = Protocol::DFRN; - } elseif (($link["rel"] == NAMESPACE_FEED) && ($link["href"] != "")) { + } elseif (($link["rel"] == NAMESPACE_FEED) && !empty($link["href"])) { $data["poll"] = $link["href"]; - } elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && ($link["type"] == "text/html") && ($link["href"] != "")) { + } elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && (defaults($link, "type", "") == "text/html") && !empty($link["href"])) { $data["url"] = $link["href"]; - } elseif (($link["rel"] == "http://microformats.org/profile/hcard") && ($link["href"] != "")) { + } elseif (($link["rel"] == "http://microformats.org/profile/hcard") && !empty($link["href"])) { $hcard_url = $link["href"]; - } elseif (($link["rel"] == NAMESPACE_POCO) && ($link["href"] != "")) { + } elseif (($link["rel"] == NAMESPACE_POCO) && !empty($link["href"])) { $data["poco"] = $link["href"]; - } elseif (($link["rel"] == "http://webfinger.net/rel/avatar") && ($link["href"] != "")) { + } elseif (($link["rel"] == "http://webfinger.net/rel/avatar") && !empty($link["href"])) { $data["photo"] = $link["href"]; - } elseif (($link["rel"] == "http://joindiaspora.com/seed_location") && ($link["href"] != "")) { + } elseif (($link["rel"] == "http://joindiaspora.com/seed_location") && !empty($link["href"])) { $data["baseurl"] = trim($link["href"], '/'); - } elseif (($link["rel"] == "http://joindiaspora.com/guid") && ($link["href"] != "")) { + } elseif (($link["rel"] == "http://joindiaspora.com/guid") && !empty($link["href"])) { $data["guid"] = $link["href"]; - } elseif (($link["rel"] == "diaspora-public-key") && ($link["href"] != "")) { + } elseif (($link["rel"] == "diaspora-public-key") && !empty($link["href"])) { $data["pubkey"] = base64_decode($link["href"]); //if (strstr($data["pubkey"], 'RSA ') || ($link["type"] == "RSA")) @@ -1169,21 +1181,21 @@ class Probe $hcard_url = ""; $data = []; foreach ($webfinger["links"] as $link) { - if (($link["rel"] == "http://microformats.org/profile/hcard") && ($link["href"] != "")) { + if (($link["rel"] == "http://microformats.org/profile/hcard") && !empty($link["href"])) { $hcard_url = $link["href"]; - } elseif (($link["rel"] == "http://joindiaspora.com/seed_location") && ($link["href"] != "")) { + } elseif (($link["rel"] == "http://joindiaspora.com/seed_location") && !empty($link["href"])) { $data["baseurl"] = trim($link["href"], '/'); - } elseif (($link["rel"] == "http://joindiaspora.com/guid") && ($link["href"] != "")) { + } elseif (($link["rel"] == "http://joindiaspora.com/guid") && !empty($link["href"])) { $data["guid"] = $link["href"]; - } elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && ($link["type"] == "text/html") && ($link["href"] != "")) { + } elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && (defaults($link, "type", "") == "text/html") && !empty($link["href"])) { $data["url"] = $link["href"]; - } elseif (($link["rel"] == NAMESPACE_FEED) && ($link["href"] != "")) { + } elseif (($link["rel"] == NAMESPACE_FEED) && !empty($link["href"])) { $data["poll"] = $link["href"]; - } elseif (($link["rel"] == NAMESPACE_POCO) && ($link["href"] != "")) { + } elseif (($link["rel"] == NAMESPACE_POCO) && !empty($link["href"])) { $data["poco"] = $link["href"]; - } elseif (($link["rel"] == "salmon") && ($link["href"] != "")) { + } elseif (($link["rel"] == "salmon") && !empty($link["href"])) { $data["notify"] = $link["href"]; - } elseif (($link["rel"] == "diaspora-public-key") && ($link["href"] != "")) { + } elseif (($link["rel"] == "diaspora-public-key") && !empty($link["href"])) { $data["pubkey"] = base64_decode($link["href"]); //if (strstr($data["pubkey"], 'RSA ') || ($link["type"] == "RSA")) @@ -1271,15 +1283,15 @@ class Probe if (is_array($webfinger["links"])) { foreach ($webfinger["links"] as $link) { if (($link["rel"] == "http://webfinger.net/rel/profile-page") - && ($link["type"] == "text/html") + && (defaults($link, "type", "") == "text/html") && ($link["href"] != "") ) { $data["url"] = $link["href"]; - } elseif (($link["rel"] == "salmon") && ($link["href"] != "")) { + } elseif (($link["rel"] == "salmon") && !empty($link["href"])) { $data["notify"] = $link["href"]; - } elseif (($link["rel"] == NAMESPACE_FEED) && ($link["href"] != "")) { + } elseif (($link["rel"] == NAMESPACE_FEED) && !empty($link["href"])) { $data["poll"] = $link["href"]; - } elseif (($link["rel"] == "magic-public-key") && ($link["href"] != "")) { + } elseif (($link["rel"] == "magic-public-key") && !empty($link["href"])) { $pubkey = $link["href"]; if (substr($pubkey, 0, 5) === 'data:') { @@ -1435,7 +1447,7 @@ class Probe $data = []; foreach ($webfinger["links"] as $link) { if (($link["rel"] == "http://webfinger.net/rel/profile-page") - && ($link["type"] == "text/html") + && (defaults($link, "type", "") == "text/html") && ($link["href"] != "") ) { $data["url"] = $link["href"]; @@ -1604,7 +1616,8 @@ class Probe $user = DBA::selectFirst('user', ['prvkey'], ['uid' => $uid]); $condition = ["`uid` = ? AND `server` != ''", $uid]; - $mailacct = DBA::selectFirst('mailacct', ['pass', 'user'], $condition); + $fields = ['pass', 'user', 'server', 'port', 'ssltype', 'mailbox']; + $mailacct = DBA::selectFirst('mailacct', $fields, $condition); if (!DBA::isResult($user) || !DBA::isResult($mailacct)) { return false;