summaryrefslogtreecommitdiffstats
path: root/apps/federation/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-02-09 13:58:13 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-02-09 14:41:26 +0100
commitbc8632856a1d2588ba8675a768ed6fe700677e55 (patch)
treeb6842bdd2d52ff8f7a3314cb1e20af0610845f21 /apps/federation/lib
parentd11179a0f5b69ae479c214033a1ffc8d64752c83 (diff)
downloadnextcloud-server-bc8632856a1d2588ba8675a768ed6fe700677e55.tar.gz
nextcloud-server-bc8632856a1d2588ba8675a768ed6fe700677e55.zip
Forward exception message to the admin in case of errors and in case the remote server version is to low and appropriate message is displayed as well
Diffstat (limited to 'apps/federation/lib')
-rw-r--r--apps/federation/lib/trustedservers.php36
1 files changed, 18 insertions, 18 deletions
diff --git a/apps/federation/lib/trustedservers.php b/apps/federation/lib/trustedservers.php
index e3ce8228cc3..340accfdbdf 100644
--- a/apps/federation/lib/trustedservers.php
+++ b/apps/federation/lib/trustedservers.php
@@ -23,6 +23,7 @@
namespace OCA\Federation;
+use OC\HintException;
use OCP\AppFramework\Http;
use OCP\BackgroundJob\IJobList;
use OCP\Http\Client\IClientService;
@@ -202,34 +203,33 @@ class TrustedServers {
public function isOwnCloudServer($url) {
$isValidOwnCloud = false;
$client = $this->httpClientService->newClient();
- 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->error($e->getMessage(), ['app' => 'federation']);
- return false;
+ $result = $client->get(
+ $url . '/status.php',
+ [
+ 'timeout' => 3,
+ 'connect_timeout' => 3,
+ ]
+ );
+ if ($result->getStatusCode() === Http::STATUS_OK) {
+ $isValidOwnCloud = $this->checkOwnCloudVersion($result->getBody());
}
+
return $isValidOwnCloud;
}
/**
* check if ownCloud version is >= 9.0
*
- * @param $statusphp
+ * @param $status
* @return bool
*/
- protected function checkOwnCloudVersion($statusphp) {
- $decoded = json_decode($statusphp, true);
+ protected function checkOwnCloudVersion($status) {
+ $decoded = json_decode($status, true);
if (!empty($decoded) && isset($decoded['version'])) {
- return version_compare($decoded['version'], '9.0.0', '>=');
+ if (!version_compare($decoded['version'], '9.0.0', '>=')) {
+ throw new HintException('Remote server version is too low. ownCloud 9.0 is required.');
+ }
+ return true;
}
return false;
}