From 8e4ae23c487b29bd8ea1a6d7d81e6996957e86fb Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 17 Oct 2018 13:09:11 +0200 Subject: Do not try to contact lookup server without internet connection or URL Signed-off-by: Arthur Schiwon --- .../lib/BackgroundJobs/RetryJob.php | 12 +++++++++--- apps/lookup_server_connector/lib/UpdateLookupServer.php | 14 ++++++++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) (limited to 'apps/lookup_server_connector/lib') diff --git a/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php b/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php index c0fba230a26..5a7212a6522 100644 --- a/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php +++ b/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php @@ -50,9 +50,15 @@ class RetryJob extends Job { $this->clientService = $clientService; $this->jobList = $jobList; + if ($config->getSystemValue('has_internet_connection', true) === false) { + return; + } + $this->lookupServer = $config->getSystemValue('lookup_server', 'https://lookup.nextcloud.com'); - $this->lookupServer = rtrim($this->lookupServer, '/'); - $this->lookupServer .= '/users'; + if (!empty($this->lookupServer)) { + $this->lookupServer = rtrim($this->lookupServer, '/'); + $this->lookupServer .= '/users'; + } } /** @@ -69,7 +75,7 @@ class RetryJob extends Job { } protected function run($argument) { - if($argument['retryNo'] === 5) { + if ($argument['retryNo'] === 5 || empty($this->lookupServer)) { return; } diff --git a/apps/lookup_server_connector/lib/UpdateLookupServer.php b/apps/lookup_server_connector/lib/UpdateLookupServer.php index ae8fcbd67ca..7902ede8816 100644 --- a/apps/lookup_server_connector/lib/UpdateLookupServer.php +++ b/apps/lookup_server_connector/lib/UpdateLookupServer.php @@ -64,15 +64,25 @@ class UpdateLookupServer { $this->signer = $signer; $this->jobList = $jobList; + if($config->getSystemValue('has_internet_connection', true) === false) { + return; + } + $this->lookupServer = $config->getSystemValue('lookup_server', 'https://lookup.nextcloud.com'); - $this->lookupServer = rtrim($this->lookupServer, '/'); - $this->lookupServer .= '/users'; + if(!empty($this->lookupServer)) { + $this->lookupServer = rtrim($this->lookupServer, '/'); + $this->lookupServer .= '/users'; + } } /** * @param IUser $user */ public function userUpdated(IUser $user) { + if(empty($this->lookupServer)) { + return; + } + $userData = $this->accountManager->getUser($user); $publicData = []; -- cgit v1.2.3