]> git.mxchange.org Git - friendica.git/blobdiff - src/Worker/UpdateServerPeers.php
version 2021.03-dev
[friendica.git] / src / Worker / UpdateServerPeers.php
index ca45344459a299663cd1f0a7ed0f092af3f533ec..d7dc7562cff1b9b008d49804c1e0f274c892ae57 100644 (file)
@@ -22,9 +22,9 @@
 namespace Friendica\Worker;
 
 use Friendica\Core\Logger;
-use Friendica\Core\Worker;
 use Friendica\Database\DBA;
 use Friendica\DI;
+use Friendica\Model\GServer;
 use Friendica\Util\Strings;
 
 class UpdateServerPeers
@@ -58,46 +58,9 @@ class UpdateServerPeers
                                continue;
                        }
                        // This endpoint doesn't offer the schema. So we assume that it is HTTPS.
-                       Worker::add(PRIORITY_LOW, 'UpdateGServer', 'https://' . $peer);
+                       GServer::add('https://' . $peer);
                        ++$added;
                }
                Logger::info('Server peer update ended', ['total' => $total, 'added' => $added, 'url' => $url]);
        }
-
-       /**
-        * Fetch server list from remote servers and adds them when they are new.
-        *
-        * @param string $poco URL to the POCO endpoint
-        */
-       private static function fetchServerlist($poco)
-       {
-               $curlResult = DI::httpRequest()->get($poco . '/@server');
-               if (!$curlResult->isSuccess()) {
-                       Logger::info('Server is not reachable or does not offer the "poco" endpoint', ['poco' => $poco]);
-                       return;
-               }
-
-               $serverlist = json_decode($curlResult->getBody(), true);
-               if (!is_array($serverlist)) {
-                       Logger::info('Server does not have any servers listed', ['poco' => $poco]);
-                       return;
-               }
-
-               Logger::info('PoCo Server update start', ['poco' => $poco]);
-
-               $total = 0;
-               $added = 0;
-               foreach ($serverlist as $server) {
-                       ++$total;
-                       if (DBA::exists('gserver', ['nurl' => Strings::normaliseLink($server['url'])])) {
-                               // We already know this server
-                               continue;
-                       }
-                       // This endpoint doesn't offer the schema. So we assume that it is HTTPS.
-                       Worker::add(PRIORITY_LOW, 'UpdateGServer', $server['url']);
-                       ++$added;
-               }
-
-               Logger::info('PoCo Server update ended', ['total' => $total, 'added' => $added, 'poco' => $poco]);
-       }
 }