]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/PortableContact.php
Replace BaseObject class with DI::* calls
[friendica.git] / src / Protocol / PortableContact.php
index 1870f8f9b76b290fafaaa88395279defc9450852..49da85e6150eae01fd6f7fa4524feaa43c59ad1f 100644 (file)
@@ -219,51 +219,6 @@ class PortableContact
                return(preg_match("=https?://.+/user/\d+=ism", $url, $matches));
        }
 
-       public static function updateNeeded($created, $updated, $last_failure, $last_contact)
-       {
-               $now = strtotime(DateTimeFormat::utcNow());
-
-               if ($updated > $last_contact) {
-                       $contact_time = strtotime($updated);
-               } else {
-                       $contact_time = strtotime($last_contact);
-               }
-
-               $failure_time = strtotime($last_failure);
-               $created_time = strtotime($created);
-
-               // If there is no "created" time then use the current time
-               if ($created_time <= 0) {
-                       $created_time = $now;
-               }
-
-               // If the last contact was less than 24 hours then don't update
-               if (($now - $contact_time) < (60 * 60 * 24)) {
-                       return false;
-               }
-
-               // If the last failure was less than 24 hours then don't update
-               if (($now - $failure_time) < (60 * 60 * 24)) {
-                       return false;
-               }
-
-               // If the last contact was less than a week ago and the last failure is older than a week then don't update
-               //if ((($now - $contact_time) < (60 * 60 * 24 * 7)) && ($contact_time > $failure_time))
-               //      return false;
-
-               // If the last contact time was more than a week ago and the contact was created more than a week ago, then only try once a week
-               if ((($now - $contact_time) > (60 * 60 * 24 * 7)) && (($now - $created_time) > (60 * 60 * 24 * 7)) && (($now - $failure_time) < (60 * 60 * 24 * 7))) {
-                       return false;
-               }
-
-               // If the last contact time was more than a month ago and the contact was created more than a month ago, then only try once a month
-               if ((($now - $contact_time) > (60 * 60 * 24 * 30)) && (($now - $created_time) > (60 * 60 * 24 * 30)) && (($now - $failure_time) < (60 * 60 * 24 * 30))) {
-                       return false;
-               }
-
-               return true;
-       }
-
        /**
         * @brief Returns a list of all known servers
         * @return array List of server urls
@@ -315,7 +270,7 @@ class PortableContact
 
                        if (!DBA::isResult($r)) {
                                Logger::log("Call server check for server ".$server_url, Logger::DEBUG);
-                               Worker::add(PRIORITY_LOW, 'CheckServer', $server_url);
+                               Worker::add(PRIORITY_LOW, 'UpdateGServer', $server_url);
                        }
                }
        }
@@ -340,7 +295,7 @@ class PortableContact
 
                        if (!empty($servers['pods'])) {
                                foreach ($servers['pods'] as $server) {
-                                       Worker::add(PRIORITY_LOW, 'CheckServer', 'https://' . $server['host']);
+                                       Worker::add(PRIORITY_LOW, 'UpdateGServer', 'https://' . $server['host']);
                                }
                        }
                }
@@ -359,7 +314,7 @@ class PortableContact
 
                                        foreach ($servers['instances'] as $server) {
                                                $url = (is_null($server['https_score']) ? 'http' : 'https') . '://' . $server['name'];
-                                               Worker::add(PRIORITY_LOW, 'CheckServer', $url);
+                                               Worker::add(PRIORITY_LOW, 'UpdateGServer', $url);
                                        }
                                }
                        }
@@ -470,7 +425,7 @@ class PortableContact
 
                $last_update = date('c', time() - (60 * 60 * 24 * $requery_days));
 
-               $gservers = q("SELECT `id`, `url`, `nurl`, `network`
+               $gservers = q("SELECT `id`, `url`, `nurl`, `network`, `poco`
                        FROM `gserver`
                        WHERE `last_contact` >= `last_failure`
                        AND `poco` != ''
@@ -488,7 +443,7 @@ class PortableContact
                                }
 
                                Logger::log('Update directory from server ' . $gserver['url'] . ' with ID ' . $gserver['id'], Logger::DEBUG);
-                               Worker::add(PRIORITY_LOW, 'UpdateServerDirectory', (int)$gserver['id']);
+                               Worker::add(PRIORITY_LOW, 'UpdateServerDirectory', $gserver);
 
                                if (!$complete && ( --$no_of_queries == 0)) {
                                        break;