diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2016-08-08 14:56:24 +0200 |
---|---|---|
committer | Bjoern Schiessle <bjoern@schiessle.org> | 2016-08-09 10:24:45 +0200 |
commit | 50044fb79265f8c7cb3e204498d0097c62274f3e (patch) | |
tree | 08028787969ffe201ec5baf71c1d387a3364ac1e /apps/federation/lib | |
parent | e4436e46cb38675fc14b608af094e4e3b5fa7c19 (diff) | |
download | nextcloud-server-50044fb79265f8c7cb3e204498d0097c62274f3e.tar.gz nextcloud-server-50044fb79265f8c7cb3e204498d0097c62274f3e.zip |
improve federation error messages
Diffstat (limited to 'apps/federation/lib')
-rw-r--r-- | apps/federation/lib/Controller/SettingsController.php | 4 | ||||
-rw-r--r-- | apps/federation/lib/DbHandler.php | 2 | ||||
-rw-r--r-- | apps/federation/lib/TrustedServers.php | 26 |
3 files changed, 19 insertions, 13 deletions
diff --git a/apps/federation/lib/Controller/SettingsController.php b/apps/federation/lib/Controller/SettingsController.php index 79eb06e0fda..40cc4c084a0 100644 --- a/apps/federation/lib/Controller/SettingsController.php +++ b/apps/federation/lib/Controller/SettingsController.php @@ -113,8 +113,8 @@ class SettingsController extends Controller { } if ($this->trustedServers->isOwnCloudServer($url) === false) { - $message = 'No server to federate found'; - $hint = $this->l->t('No server to federate found'); + $message = 'No server to federate with found'; + $hint = $this->l->t('No server to federate with found'); throw new HintException($message, $hint); } diff --git a/apps/federation/lib/DbHandler.php b/apps/federation/lib/DbHandler.php index b30ce740092..c938cfb1583 100644 --- a/apps/federation/lib/DbHandler.php +++ b/apps/federation/lib/DbHandler.php @@ -89,7 +89,7 @@ class DbHandler { if ($result) { return (int)$this->connection->lastInsertId('*PREFIX*'.$this->dbTable); } else { - $message = 'Internal failure, Could not add ownCloud as trusted server: ' . $url; + $message = 'Internal failure, Could not add trusted server: ' . $url; $message_t = $this->IL10N->t('Could not add server'); throw new HintException($message, $message_t); } diff --git a/apps/federation/lib/TrustedServers.php b/apps/federation/lib/TrustedServers.php index fff19e414d5..f802af594dc 100644 --- a/apps/federation/lib/TrustedServers.php +++ b/apps/federation/lib/TrustedServers.php @@ -211,7 +211,7 @@ class TrustedServers { } /** - * check if URL point to a ownCloud server + * check if URL point to a ownCloud/Nextcloud server * * @param string $url * @return bool @@ -219,15 +219,21 @@ class TrustedServers { public function isOwnCloudServer($url) { $isValidOwnCloud = false; $client = $this->httpClientService->newClient(); - $result = $client->get( - $url . '/status.php', - [ - 'timeout' => 3, - 'connect_timeout' => 3, - ] - ); - if ($result->getStatusCode() === Http::STATUS_OK) { - $isValidOwnCloud = $this->checkOwnCloudVersion($result->getBody()); + try { + $result = $client->get( + $url . '/status.php', + [ + 'timeout' => 3, + 'connect_timeout' => 3, + ] + ); + if ($result->getStatusCode() === Http::STATUS_OK) { + $isValidOwnCloud = $this->checkOwnCloudVersion($result->getBody()); + + } + } catch (\Exception $e) { + $this->logger->debug('No Nextcloud server: ' . $e->getMessage()); + return false; } return $isValidOwnCloud; |