X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=src%2FWorker%2FUpdateServerDirectory.php;h=c7a3b8b2b3ad37ff67b84b3b7fdba75d9515376f;hb=f61fd93db02bc2d66e1473ca34dc1154e77217a3;hp=2066ce7cb924e31255a97ac2a6ed0cb0e2f532a8;hpb=0c73531da1d93f218a47c798ae5db1d00144a7be;p=friendica.git diff --git a/src/Worker/UpdateServerDirectory.php b/src/Worker/UpdateServerDirectory.php index 2066ce7cb9..c7a3b8b2b3 100644 --- a/src/Worker/UpdateServerDirectory.php +++ b/src/Worker/UpdateServerDirectory.php @@ -1,6 +1,6 @@ $gserver['url']]); if ($gserver['directory-type'] == GServer::DT_MASTODON) { self::discoverMastodonDirectory($gserver); } elseif (!empty($gserver['poco'])) { @@ -46,7 +45,7 @@ class UpdateServerDirectory private static function discoverPoCo(array $gserver) { - $result = DI::httpRequest()->fetch($gserver['poco'] . '?fields=urls'); + $result = DI::httpClient()->fetch($gserver['poco'] . '?fields=urls', HttpClientAccept::JSON); if (empty($result)) { Logger::info('Empty result', ['url' => $gserver['url']]); return; @@ -61,8 +60,8 @@ class UpdateServerDirectory Logger::info('PoCo discovery started', ['poco' => $gserver['poco']]); $urls = []; - foreach ($contacts['entry'] as $entry) { - foreach ($entry['urls'] as $url_entry) { + foreach (array_column($contacts['entry'], 'urls') as $url_entries) { + foreach ($url_entries as $url_entry) { if (empty($url_entry['type']) || empty($url_entry['value'])) { continue; } @@ -72,14 +71,14 @@ class UpdateServerDirectory } } - $result = Contact::addContactsByArray($urls); + $result = Contact::addByUrls($urls); - Logger::info('PoCo discovery ended', ['count' => $result['count'], 'added' => $result['added'], 'updated' => $result['updated'], 'poco' => $gserver['poco']]); + Logger::info('PoCo discovery ended', ['count' => $result['count'], 'added' => $result['added'], 'updated' => $result['updated'], 'unchanged' => $result['unchanged'], 'poco' => $gserver['poco']]); } private static function discoverMastodonDirectory(array $gserver) - { - $result = DI::httpRequest()->fetch($gserver['url'] . '/api/v1/directory?order=new&local=true&limit=200&offset=0'); + { + $result = DI::httpClient()->fetch($gserver['url'] . '/api/v1/directory?order=new&local=true&limit=200&offset=0', HttpClientAccept::JSON); if (empty($result)) { Logger::info('Empty result', ['url' => $gserver['url']]); return; @@ -100,8 +99,8 @@ class UpdateServerDirectory } } - $result = Contact::addContactsByArray($urls); + $result = Contact::addByUrls($urls); - Logger::info('Account discovery ended', ['count' => $result['count'], 'added' => $result['added'], 'updated' => $result['updated'], 'url' => $gserver['url']]); + Logger::info('Account discovery ended', ['count' => $result['count'], 'added' => $result['added'], 'updated' => $result['updated'], 'unchanged' => $result['unchanged'], 'url' => $gserver['url']]); } }