X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FWorker%2FUpdateServerPeers.php;h=98ae88a97b5be8acded06a0dc1a0f040ecfc4a10;hb=60532ee7e4152af9997e0d7b69c7b35262d5528d;hp=ca45344459a299663cd1f0a7ed0f092af3f533ec;hpb=aa0b485f3dca72c5448076e913fa54d948cd7731;p=friendica.git diff --git a/src/Worker/UpdateServerPeers.php b/src/Worker/UpdateServerPeers.php index ca45344459..98ae88a97b 100644 --- a/src/Worker/UpdateServerPeers.php +++ b/src/Worker/UpdateServerPeers.php @@ -1,6 +1,6 @@ get($url . '/api/v1/instance/peers'); + $ret = DI::httpClient()->get($url . '/api/v1/instance/peers', HttpClientAccept::JSON); if (!$ret->isSuccess() || empty($ret->getBody())) { Logger::info('Server is not reachable or does not offer the "peers" endpoint', ['url' => $url]); return; @@ -58,46 +59,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]); - } }