diff options
author | Joas Schilling <coding@schilljs.com> | 2019-04-17 15:38:24 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2019-07-18 11:24:35 +0200 |
commit | 9927909a0d567c87ec85b52f8c378fa1dc56ed3b (patch) | |
tree | adcff3e31d97432b51fd894848c88aca75defe78 /apps/lookup_server_connector | |
parent | 3a4f6302ca415206e34de355289a211b9afa0e6f (diff) | |
download | nextcloud-server-9927909a0d567c87ec85b52f8c378fa1dc56ed3b.tar.gz nextcloud-server-9927909a0d567c87ec85b52f8c378fa1dc56ed3b.zip |
Always use a background job for the update
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/lookup_server_connector')
-rw-r--r-- | apps/lookup_server_connector/lib/UpdateLookupServer.php | 44 |
1 files changed, 9 insertions, 35 deletions
diff --git a/apps/lookup_server_connector/lib/UpdateLookupServer.php b/apps/lookup_server_connector/lib/UpdateLookupServer.php index 75da45dce2f..2e803ffe4b8 100644 --- a/apps/lookup_server_connector/lib/UpdateLookupServer.php +++ b/apps/lookup_server_connector/lib/UpdateLookupServer.php @@ -38,8 +38,6 @@ use OCP\IUser; class UpdateLookupServer { /** @var AccountManager */ private $accountManager; - /** @var IClientService */ - private $clientService; /** @var Signer */ private $signer; /** @var IJobList */ @@ -51,18 +49,15 @@ class UpdateLookupServer { /** * @param AccountManager $accountManager - * @param IClientService $clientService * @param Signer $signer * @param IJobList $jobList * @param IConfig $config */ public function __construct(AccountManager $accountManager, - IClientService $clientService, Signer $signer, IJobList $jobList, IConfig $config) { $this->accountManager = $accountManager; - $this->clientService = $clientService; $this->signer = $signer; $this->jobList = $jobList; @@ -82,7 +77,7 @@ class UpdateLookupServer { /** * @param IUser $user */ - public function userUpdated(IUser $user) { + public function userUpdated(IUser $user): void { if (!$this->shouldUpdateLookupServer()) { return; @@ -106,7 +101,7 @@ class UpdateLookupServer { * @param IUser $user * @param array $publicData */ - protected function sendToLookupServer(IUser $user, array $publicData) { + protected function sendToLookupServer(IUser $user, array $publicData): void { $dataArray = ['federationId' => $user->getCloudId()]; @@ -127,33 +122,12 @@ class UpdateLookupServer { } $dataArray = $this->signer->sign('lookupserver', $dataArray, $user); - $httpClient = $this->clientService->newClient(); - try { - if (empty($publicData)) { - $httpClient->delete($this->lookupServer, - [ - 'body' => json_encode($dataArray), - 'timeout' => 10, - 'connect_timeout' => 3, - ] - ); - } else { - $httpClient->post($this->lookupServer, - [ - 'body' => json_encode($dataArray), - 'timeout' => 10, - 'connect_timeout' => 3, - ] - ); - } - } catch (\Exception $e) { - $this->jobList->add(RetryJob::class, - [ - 'dataArray' => $dataArray, - 'retryNo' => 0, - ] - ); - } + $this->jobList->add(RetryJob::class, + [ + 'dataArray' => $dataArray, + 'retryNo' => 0, + ] + ); } /** @@ -164,7 +138,7 @@ class UpdateLookupServer { * * @return bool */ - private function shouldUpdateLookupServer() { + private function shouldUpdateLookupServer(): bool { return $this->lookupServerEnabled && !empty($this->lookupServer); } |