]> git.mxchange.org Git - friendica.git/commitdiff
Readded the network parameter
authorMichael <heluecht@pirati.ca>
Fri, 4 Oct 2019 05:42:54 +0000 (05:42 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 4 Oct 2019 05:42:54 +0000 (05:42 +0000)
src/Model/GContact.php
src/Model/GServer.php
src/Protocol/PortableContact.php
src/Worker/DiscoverPoCo.php

index 89737cc0847c7d29477e068523ce60579f2bd84e..23415d1078671192b6ae1faba750a3bd3e1c0d3c 100644 (file)
@@ -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'] = "";
                }
 
index b3cc6fc41b9b1ab2488cd0bd3c20ab974689a5d2..05ea0baacc1a6f2c61a537411899f12936a739e6 100644 (file)
@@ -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 = [];
 
index 826fc108c8c9bbbb2a52bf2da51579b2cc56e15b..235c17ff59563734d4c2db0f0b7574672bd621d4 100644 (file)
@@ -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']]);
index bee94a77d1652038212a81ffd03a8d6273312db5..5ce4c97d6f421a88e10025245a9ca66efb38c639 100644 (file)
@@ -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"]);