summaryrefslogtreecommitdiffstats
path: root/apps/federation
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2016-02-26 17:51:20 +0100
committerBjoern Schiessle <schiessle@owncloud.com>2016-02-29 16:50:34 +0100
commit87e47afed85521439c351ae30e9849f0a74a399d (patch)
treea644b7fe1d822deaeee9fb86fd9d10cc952ddf9d /apps/federation
parent7189c72c33a03d57473f7e3443193d07bece7c15 (diff)
downloadnextcloud-server-87e47afed85521439c351ae30e9849f0a74a399d.tar.gz
nextcloud-server-87e47afed85521439c351ae30e9849f0a74a399d.zip
remove synced remote address book if the remote server revoked access to his system address book
Diffstat (limited to 'apps/federation')
-rw-r--r--apps/federation/command/syncfederationaddressbooks.php1
-rw-r--r--apps/federation/lib/syncfederationaddressbooks.php4
-rw-r--r--apps/federation/lib/trustedservers.php2
-rw-r--r--apps/federation/templates/settings-admin.php6
4 files changed, 12 insertions, 1 deletions
diff --git a/apps/federation/command/syncfederationaddressbooks.php b/apps/federation/command/syncfederationaddressbooks.php
index 61703d9d4e4..72d12e59b22 100644
--- a/apps/federation/command/syncfederationaddressbooks.php
+++ b/apps/federation/command/syncfederationaddressbooks.php
@@ -40,6 +40,7 @@ class SyncFederationAddressBooks extends Command {
$this->syncService->syncThemAll(function($url, $ex) use ($progress, $output) {
if ($ex instanceof \Exception) {
$output->writeln("Error while syncing $url : " . $ex->getMessage());
+
} else {
$progress->advance();
}
diff --git a/apps/federation/lib/syncfederationaddressbooks.php b/apps/federation/lib/syncfederationaddressbooks.php
index 886f6505b20..f9cee9a7137 100644
--- a/apps/federation/lib/syncfederationaddressbooks.php
+++ b/apps/federation/lib/syncfederationaddressbooks.php
@@ -3,6 +3,7 @@
namespace OCA\Federation;
use OCA\DAV\CardDAV\SyncService;
+use OCP\AppFramework\Http;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputInterface;
@@ -51,6 +52,9 @@ class SyncFederationAddressBooks {
$this->dbHandler->setServerStatus($url, TrustedServers::STATUS_OK, $newToken);
}
} catch (\Exception $ex) {
+ if ($ex->getCode() === Http::STATUS_UNAUTHORIZED) {
+ $this->dbHandler->setServerStatus($url, TrustedServers::STATUS_ACCESS_REVOKED);
+ }
$callback($url, $ex);
}
}
diff --git a/apps/federation/lib/trustedservers.php b/apps/federation/lib/trustedservers.php
index fed6b0944a8..3d515f24a7c 100644
--- a/apps/federation/lib/trustedservers.php
+++ b/apps/federation/lib/trustedservers.php
@@ -41,6 +41,8 @@ class TrustedServers {
const STATUS_PENDING = 2;
/** something went wrong, misconfigured server, software bug,... user interaction needed */
const STATUS_FAILURE = 3;
+ /** remote server revoked access */
+ const STATUS_ACCESS_REVOKED = 4;
/** @var dbHandler */
private $dbHandler;
diff --git a/apps/federation/templates/settings-admin.php b/apps/federation/templates/settings-admin.php
index 854bb744179..77c552ee789 100644
--- a/apps/federation/templates/settings-admin.php
+++ b/apps/federation/templates/settings-admin.php
@@ -26,7 +26,11 @@ style('federation', 'settings-admin')
<li id="<?php p($trustedServer['id']); ?>" class="icon-delete">
<?php if((int)$trustedServer['status'] === TrustedServers::STATUS_OK) { ?>
<span class="status success"></span>
- <?php } elseif((int)$trustedServer['status'] === TrustedServers::STATUS_PENDING) { ?>
+ <?php
+ } elseif(
+ (int)$trustedServer['status'] === TrustedServers::STATUS_PENDING ||
+ (int)$trustedServer['status'] === TrustedServers::STATUS_ACCESS_REVOKED
+ ) { ?>
<span class="status indeterminate"></span>
<?php } else {?>
<span class="status error"></span>