]> git.mxchange.org Git - friendica.git/commitdiff
Renamed functions
authorMichael <heluecht@pirati.ca>
Sat, 21 Dec 2019 18:57:00 +0000 (18:57 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 21 Dec 2019 18:57:00 +0000 (18:57 +0000)
src/Worker/Cron.php
src/Worker/DiscoverContacts.php [deleted file]
src/Worker/DiscoverPoCo.php [deleted file]
src/Worker/UpdateGContacts.php [new file with mode: 0644]
src/Worker/UpdateGServers.php [new file with mode: 0644]
src/Worker/UpdateServerDirectories.php [new file with mode: 0644]
src/Worker/UpdateServers.php [deleted file]

index 356be46e44b694987689c4394e620a806ec7b057..6928cb8d79c2875b2c08970571526480f62628a5 100644 (file)
@@ -38,11 +38,11 @@ class Cron
                // Fork the cron jobs in separate parts to avoid problems when one of them is crashing
                Hook::fork($a->queue['priority'], "cron");
 
-               // run the process to discover global contacts in the background
-               Worker::add(PRIORITY_LOW, "DiscoverPoCo");
+               // run the process to update server directories in the background
+               Worker::add(PRIORITY_LOW, 'UpdateServerDirectories');
 
                // run the process to update locally stored global contacts in the background
-               Worker::add(PRIORITY_LOW, 'DiscoverContacts');
+               Worker::add(PRIORITY_LOW, 'UpdateGContacts');
 
                // Expire and remove user entries
                Worker::add(PRIORITY_MEDIUM, "CronJobs", "expire_and_remove_users");
@@ -73,7 +73,7 @@ class Cron
                        // update nodeinfo data
                        Worker::add(PRIORITY_LOW, "CronJobs", "nodeinfo");
 
-                       Worker::add(PRIORITY_LOW, 'UpdateServers');
+                       Worker::add(PRIORITY_LOW, 'UpdateGServers');
 
                        Worker::add(PRIORITY_LOW, 'UpdateSuggestions');
 
diff --git a/src/Worker/DiscoverContacts.php b/src/Worker/DiscoverContacts.php
deleted file mode 100644 (file)
index 7af170b..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-<?php
-/**
- * @file src/Worker/DiscoverContacts.php
- */
-namespace Friendica\Worker;
-
-use Friendica\Core\Config;
-use Friendica\Core\Logger;
-use Friendica\Core\Protocol;
-use Friendica\Core\Worker;
-use Friendica\Database\DBA;
-use Friendica\Model\Contact;
-use Friendica\Model\GServer;
-use Friendica\Util\DateTimeFormat;
-use Friendica\Util\Strings;
-
-class DiscoverContacts
-{
-       // Updates gcontact entries
-       public static function execute()
-       {
-               if (!Config::get('system', 'poco_completion')) {
-                       return;
-               }
-
-               Logger::info('Discover contacts');
-
-               $starttime = time();
-
-               $contacts = DBA::p("SELECT `url`, `created`, `updated`, `last_failure`, `last_contact`, `server_url`, `network` FROM `gcontact`
-                               WHERE `last_contact` < UTC_TIMESTAMP - INTERVAL 1 MONTH AND
-                                       `last_failure` < UTC_TIMESTAMP - INTERVAL 1 MONTH AND
-                                       `network` IN (?, ?, ?, ?, '') ORDER BY rand()",
-                               Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, Protocol::FEED);
-
-               $checked = 0;
-
-               while ($contact = DBA::fetch($contacts)) {
-                       $urlparts = parse_url($contact['url']);
-                       if (empty($urlparts['scheme'])) {
-                               DBA::update('gcontact', ['network' => Protocol::PHANTOM],
-                                       ['nurl' => Strings::normaliseLink($contact['url'])]);
-                               continue;
-                        }
-
-                       if (in_array($urlparts['host'], ['twitter.com', 'identi.ca'])) {
-                               $networks = ['twitter.com' => Protocol::TWITTER, 'identi.ca' => Protocol::PUMPIO];
-
-                               DBA::update('gcontact', ['network' => $networks[$urlparts['host']]],
-                                       ['nurl' => Strings::normaliseLink($contact['url'])]);
-                               continue;
-                       }
-
-                       $server_url = Contact::getBasepath($contact['url']);
-                       $force_update = false;
-
-                       if (!empty($contact['server_url'])) {
-                               $force_update = (Strings::normaliseLink($contact['server_url']) != Strings::normaliseLink($server_url));
-
-                               $server_url = $contact['server_url'];
-                       }
-
-                       if ((empty($server_url) && ($contact['network'] == Protocol::FEED)) || $force_update || GServer::check($server_url, $contact['network'])) {
-                               Logger::info('Check profile', ['profile' => $contact['url']]);
-                               Worker::add(PRIORITY_LOW, 'UpdateGContact', $contact['url'], 'force');
-
-                               if (++$checked > 100) {
-                                       return;
-                               }
-                       } else {
-                               DBA::update('gcontact', ['last_failure' => DateTimeFormat::utcNow()],
-                                       ['nurl' => Strings::normaliseLink($contact['url'])]);
-                       }
-
-                       // Quit the loop after 3 minutes
-                       if (time() > ($starttime + 180)) {
-                               return;
-                       }
-               }
-       }
-}
diff --git a/src/Worker/DiscoverPoCo.php b/src/Worker/DiscoverPoCo.php
deleted file mode 100644 (file)
index 29b5d4f..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-/**
- * @file src/Worker/DiscoverPoCo.php
- */
-namespace Friendica\Worker;
-
-use Friendica\Core\Config;
-use Friendica\Core\Logger;
-use Friendica\Model\GContact;
-use Friendica\Protocol\PortableContact;
-
-class DiscoverPoCo
-{
-       public static function execute()
-       {
-               if (Config::get('system', 'poco_discovery') == PortableContact::DISABLED) {
-                       return;
-               }
-
-               // Query Friendica and Hubzilla servers for their users
-               PortableContact::discover();
-
-               // Query GNU Social servers for their users ("statistics" addon has to be enabled on the GS server)
-               if (!Config::get('system', 'ostatus_disabled')) {
-                       GContact::discoverGsUsers();
-               }
-       }
-}
diff --git a/src/Worker/UpdateGContacts.php b/src/Worker/UpdateGContacts.php
new file mode 100644 (file)
index 0000000..64ffb2a
--- /dev/null
@@ -0,0 +1,81 @@
+<?php
+/**
+ * @file src/Worker/UpdateGContacts.php
+ */
+namespace Friendica\Worker;
+
+use Friendica\Core\Config;
+use Friendica\Core\Logger;
+use Friendica\Core\Protocol;
+use Friendica\Core\Worker;
+use Friendica\Database\DBA;
+use Friendica\Model\Contact;
+use Friendica\Model\GServer;
+use Friendica\Util\DateTimeFormat;
+use Friendica\Util\Strings;
+
+class UpdateGContacts
+{
+       // Updates gcontact entries
+       public static function execute()
+       {
+               if (!Config::get('system', 'poco_completion')) {
+                       return;
+               }
+
+               Logger::info('Discover contacts');
+
+               $starttime = time();
+
+               $contacts = DBA::p("SELECT `url`, `created`, `updated`, `last_failure`, `last_contact`, `server_url`, `network` FROM `gcontact`
+                               WHERE `last_contact` < UTC_TIMESTAMP - INTERVAL 1 MONTH AND
+                                       `last_failure` < UTC_TIMESTAMP - INTERVAL 1 MONTH AND
+                                       `network` IN (?, ?, ?, ?, '') ORDER BY rand()",
+                               Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, Protocol::FEED);
+
+               $checked = 0;
+
+               while ($contact = DBA::fetch($contacts)) {
+                       $urlparts = parse_url($contact['url']);
+                       if (empty($urlparts['scheme'])) {
+                               DBA::update('gcontact', ['network' => Protocol::PHANTOM],
+                                       ['nurl' => Strings::normaliseLink($contact['url'])]);
+                               continue;
+                        }
+
+                       if (in_array($urlparts['host'], ['twitter.com', 'identi.ca'])) {
+                               $networks = ['twitter.com' => Protocol::TWITTER, 'identi.ca' => Protocol::PUMPIO];
+
+                               DBA::update('gcontact', ['network' => $networks[$urlparts['host']]],
+                                       ['nurl' => Strings::normaliseLink($contact['url'])]);
+                               continue;
+                       }
+
+                       $server_url = Contact::getBasepath($contact['url']);
+                       $force_update = false;
+
+                       if (!empty($contact['server_url'])) {
+                               $force_update = (Strings::normaliseLink($contact['server_url']) != Strings::normaliseLink($server_url));
+
+                               $server_url = $contact['server_url'];
+                       }
+
+                       if ((empty($server_url) && ($contact['network'] == Protocol::FEED)) || $force_update || GServer::check($server_url, $contact['network'])) {
+                               Logger::info('Check profile', ['profile' => $contact['url']]);
+                               Worker::add(PRIORITY_LOW, 'UpdateGContact', $contact['url'], 'force');
+
+                               if (++$checked > 100) {
+                                       return;
+                               }
+                       } else {
+                               DBA::update('gcontact', ['last_failure' => DateTimeFormat::utcNow()],
+                                       ['nurl' => Strings::normaliseLink($contact['url'])]);
+                       }
+
+                       // Quit the loop after 3 minutes
+                       if (time() > ($starttime + 180)) {
+                               return;
+                       }
+               }
+       }
+}
diff --git a/src/Worker/UpdateGServers.php b/src/Worker/UpdateGServers.php
new file mode 100644 (file)
index 0000000..a245c34
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+/**
+ * @file src/Worker/UpdateGServers.php
+ */
+namespace Friendica\Worker;
+
+use Friendica\Core\Logger;
+use Friendica\Core\Worker;
+use Friendica\Database\DBA;
+use Friendica\Model\GServer;
+
+class UpdateGServers
+{
+       /**
+        * @brief Updates the first 250 servers
+        *
+        */
+       public static function execute()
+       {
+               $gservers = DBA::p("SELECT `url`, `created`, `last_failure`, `last_contact` FROM `gserver` ORDER BY rand()");
+               if (!DBA::isResult($gservers)) {
+                       return;
+               }
+
+               $updated = 0;
+
+               while ($gserver = DBA::fetch($gservers)) {
+                       if (!GServer::updateNeeded($gserver['created'], '', $gserver['last_failure'], $gserver['last_contact'])) {
+                               continue;
+                       }
+                       Logger::info('Update server status', ['server' => $gserver['url']]);
+
+                       Worker::add(PRIORITY_LOW, 'UpdateGServer', $gserver['url']);
+
+                       if (++$updated > 250) {
+                               return;
+                       }
+               }
+       }
+}
diff --git a/src/Worker/UpdateServerDirectories.php b/src/Worker/UpdateServerDirectories.php
new file mode 100644 (file)
index 0000000..e1b1203
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+/**
+ * @file src/Worker/UpdateServerDirectories.php
+ */
+namespace Friendica\Worker;
+
+use Friendica\Core\Config;
+use Friendica\Core\Logger;
+use Friendica\Model\GContact;
+use Friendica\Protocol\PortableContact;
+
+class UpdateServerDirectories
+{
+       public static function execute()
+       {
+               if (Config::get('system', 'poco_discovery') == PortableContact::DISABLED) {
+                       return;
+               }
+
+               // Query Friendica and Hubzilla servers for their users
+               PortableContact::discover();
+
+               // Query GNU Social servers for their users ("statistics" addon has to be enabled on the GS server)
+               if (!Config::get('system', 'ostatus_disabled')) {
+                       GContact::discoverGsUsers();
+               }
+       }
+}
diff --git a/src/Worker/UpdateServers.php b/src/Worker/UpdateServers.php
deleted file mode 100644 (file)
index d1cc042..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-/**
- * @file src/Worker/UpdateServers.php
- */
-namespace Friendica\Worker;
-
-use Friendica\Core\Logger;
-use Friendica\Core\Worker;
-use Friendica\Database\DBA;
-use Friendica\Model\GServer;
-
-class UpdateServers
-{
-       /**
-        * @brief Updates the first 250 servers
-        *
-        */
-       public static function execute()
-       {
-               $gservers = DBA::p("SELECT `url`, `created`, `last_failure`, `last_contact` FROM `gserver` ORDER BY rand()");
-               if (!DBA::isResult($gservers)) {
-                       return;
-               }
-
-               $updated = 0;
-
-               while ($gserver = DBA::fetch($gservers)) {
-                       if (!GServer::updateNeeded($gserver['created'], '', $gserver['last_failure'], $gserver['last_contact'])) {
-                               continue;
-                       }
-                       Logger::info('Update server status', ['server' => $gserver['url']]);
-
-                       Worker::add(PRIORITY_LOW, 'UpdateGServer', $gserver['url']);
-
-                       if (++$updated > 250) {
-                               return;
-                       }
-               }
-       }
-}