Merge pull request #788 from nextcloud/stable10-federation-error-messages
[stable10] improve federation error messages
This commit is contained in:
commit
289704f13d
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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,6 +219,7 @@ class TrustedServers {
|
|||
public function isOwnCloudServer($url) {
|
||||
$isValidOwnCloud = false;
|
||||
$client = $this->httpClientService->newClient();
|
||||
try {
|
||||
$result = $client->get(
|
||||
$url . '/status.php',
|
||||
[
|
||||
|
@ -228,6 +229,11 @@ class TrustedServers {
|
|||
);
|
||||
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;
|
||||
|
|
|
@ -309,7 +309,6 @@ class TrustedServersTest extends TestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
* @expectedExceptionMessage simulated exception
|
||||
*/
|
||||
public function testIsOwnCloudServerFail() {
|
||||
|
@ -323,7 +322,7 @@ class TrustedServersTest extends TestCase {
|
|||
throw new \Exception('simulated exception');
|
||||
});
|
||||
|
||||
$this->trustedServers->isOwnCloudServer($server);
|
||||
$this->assertFalse($this->trustedServers->isOwnCloudServer($server));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue