From a7e518acbd8ecc39276f24f74113b18529fcebb1 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 4 Oct 2019 05:42:54 +0000 Subject: [PATCH] Readded the network parameter --- src/Model/GContact.php | 2 +- src/Model/GServer.php | 12 +++++++----- src/Protocol/PortableContact.php | 8 ++++---- src/Worker/DiscoverPoCo.php | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/Model/GContact.php b/src/Model/GContact.php index 89737cc084..23415d1078 100644 --- a/src/Model/GContact.php +++ b/src/Model/GContact.php @@ -231,7 +231,7 @@ class GContact } // The server URL doesn't seem to be valid, so we don't store it. - if (!GServer::check($gcontact['server_url'])) { + if (!GServer::check($gcontact['server_url'], $gcontact['network'])) { $gcontact['server_url'] = ""; } diff --git a/src/Model/GServer.php b/src/Model/GServer.php index b3cc6fc41b..05ea0baacc 100644 --- a/src/Model/GServer.php +++ b/src/Model/GServer.php @@ -25,7 +25,7 @@ use Friendica\Protocol\Diaspora; */ class GServer { - public static function check($server_url, $force = false) + public static function check($server_url, $network = '', $force = false) { // Unify the server address $server_url = trim($server_url, '/'); @@ -57,13 +57,15 @@ class GServer } if (!$force && !PortableContact::updateNeeded($gserver['created'], '', $last_failure, $last_contact)) { - Logger::info('Use cached data', ['server' => $server_url]); + Logger::info('No update needed', ['server' => $server_url]); return ($last_contact >= $last_failure); } + Logger::info('Server is outdated. Start discovery.', ['Server' => $server_url, 'Force' => $force, 'Created' => $gserver['created'], 'Failure' => $last_failure, 'Contact' => $last_contact]); + } else { + Logger::info('Server is unknown. Start discovery.', ['Server' => $server_url]); } - Logger::info('Server is outdated or unknown. Start discovery.', ['Server' => $server_url, 'Force' => $force, 'Created' => $gserver['created'], 'Failure' => $last_failure, 'Contact' => $last_contact]); - return self::detect($server_url); + return self::detect($server_url, $network); } /** @@ -74,7 +76,7 @@ class GServer * * @return boolean 'true' if server could be detected */ - public static function detect($url) + public static function detect($url, $network = '') { $serverdata = []; diff --git a/src/Protocol/PortableContact.php b/src/Protocol/PortableContact.php index 826fc108c8..235c17ff59 100644 --- a/src/Protocol/PortableContact.php +++ b/src/Protocol/PortableContact.php @@ -224,7 +224,7 @@ class PortableContact return true; } - return GServer::check($server, $force); + return GServer::check($server, $network, $force); } public static function alternateOStatusUrl($url) @@ -268,7 +268,7 @@ class PortableContact } if ($server_url != "") { - if (!GServer::check($server_url, $force)) { + if (!GServer::check($server_url, $gcontacts[0]["network"], $force)) { if ($force) { $fields = ['last_failure' => DateTimeFormat::utcNow()]; DBA::update('gcontact', $fields, ['nurl' => Strings::normaliseLink($profile)]); @@ -705,7 +705,7 @@ class PortableContact return true; } else { // If the server hadn't replied correctly, then force a sanity check - GServer::check($server["url"], true); + GServer::check($server["url"], $server["network"], true); // If we couldn't reach the server, we will try it some time later $fields = ['last_poco_query' => DateTimeFormat::utcNow()]; @@ -740,7 +740,7 @@ class PortableContact if (DBA::isResult($gservers)) { foreach ($gservers as $gserver) { - if (!GServer::check($gserver['url'])) { + if (!GServer::check($gserver['url'], $gserver['network'])) { // The server is not reachable? Okay, then we will try it later $fields = ['last_poco_query' => DateTimeFormat::utcNow()]; DBA::update('gserver', $fields, ['nurl' => $gserver['nurl']]); diff --git a/src/Worker/DiscoverPoCo.php b/src/Worker/DiscoverPoCo.php index bee94a77d1..5ce4c97d6f 100644 --- a/src/Worker/DiscoverPoCo.php +++ b/src/Worker/DiscoverPoCo.php @@ -187,7 +187,7 @@ class DiscoverPoCo $server_url = $user["server_url"]; } - if ((($server_url == "") && ($user["network"] == Protocol::FEED)) || $force_update || GServer::check($server_url)) { + if ((($server_url == "") && ($user["network"] == Protocol::FEED)) || $force_update || GServer::check($server_url, $user["network"])) { Logger::log('Check profile '.$user["url"]); Worker::add(PRIORITY_LOW, "DiscoverPoCo", "check_profile", $user["url"]); -- 2.39.5