diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2017-03-03 14:31:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-03 14:31:21 +0100 |
commit | 53a484ede6b0211f42c6e0cdb85916ae5e034611 (patch) | |
tree | d68b3c3c024a59a358e689399c169648929331d2 | |
parent | 8e27b8197d8b869e8fb0d55105f9bfc2f854b381 (diff) | |
parent | dda15b74cb76d5958006a5dce0f2074c5fb3bb99 (diff) | |
download | nextcloud-server-53a484ede6b0211f42c6e0cdb85916ae5e034611.tar.gz nextcloud-server-53a484ede6b0211f42c6e0cdb85916ae5e034611.zip |
Merge pull request #3597 from nextcloud/remove-data-from-lookup-server
add posibility to remove all personal data from lookup server
-rw-r--r-- | apps/lookup_server_connector/lib/UpdateLookupServer.php | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/apps/lookup_server_connector/lib/UpdateLookupServer.php b/apps/lookup_server_connector/lib/UpdateLookupServer.php index 7ba63c85567..86865311725 100644 --- a/apps/lookup_server_connector/lib/UpdateLookupServer.php +++ b/apps/lookup_server_connector/lib/UpdateLookupServer.php @@ -93,9 +93,7 @@ class UpdateLookupServer { } } - if (!empty($publicData)) { - $this->sendToLookupServer($user, $publicData); - } + $this->sendToLookupServer($user, $publicData); } /** @@ -105,25 +103,38 @@ class UpdateLookupServer { * @param array $publicData */ protected function sendToLookupServer(IUser $user, array $publicData) { - $dataArray = [ - 'federationId' => $user->getCloudId(), - 'name' => isset($publicData[AccountManager::PROPERTY_DISPLAYNAME]) ? $publicData[AccountManager::PROPERTY_DISPLAYNAME]['value'] : '', - 'email' => isset($publicData[AccountManager::PROPERTY_EMAIL]) ? $publicData[AccountManager::PROPERTY_EMAIL]['value'] : '', - 'address' => isset($publicData[AccountManager::PROPERTY_ADDRESS]) ? $publicData[AccountManager::PROPERTY_ADDRESS]['value'] : '', - 'website' => isset($publicData[AccountManager::PROPERTY_WEBSITE]) ? $publicData[AccountManager::PROPERTY_WEBSITE]['value'] : '', - 'twitter' => isset($publicData[AccountManager::PROPERTY_TWITTER]) ? $publicData[AccountManager::PROPERTY_TWITTER]['value'] : '', - 'phone' => isset($publicData[AccountManager::PROPERTY_PHONE]) ? $publicData[AccountManager::PROPERTY_PHONE]['value'] : '', - ]; + + $dataArray = ['federationId' => $user->getCloudId()]; + + if (!empty($publicData)) { + $dataArray['name'] = isset($publicData[AccountManager::PROPERTY_DISPLAYNAME]) ? $publicData[AccountManager::PROPERTY_DISPLAYNAME]['value'] : ''; + $dataArray['email'] = isset($publicData[AccountManager::PROPERTY_EMAIL]) ? $publicData[AccountManager::PROPERTY_EMAIL]['value'] : ''; + $dataArray['address'] = isset($publicData[AccountManager::PROPERTY_ADDRESS]) ? $publicData[AccountManager::PROPERTY_ADDRESS]['value'] : ''; + $dataArray['website'] = isset($publicData[AccountManager::PROPERTY_WEBSITE]) ? $publicData[AccountManager::PROPERTY_WEBSITE]['value'] : ''; + $dataArray['twitter'] = isset($publicData[AccountManager::PROPERTY_TWITTER]) ? $publicData[AccountManager::PROPERTY_TWITTER]['value'] : ''; + $dataArray['phone'] = isset($publicData[AccountManager::PROPERTY_PHONE]) ? $publicData[AccountManager::PROPERTY_PHONE]['value'] : ''; + } + $dataArray = $this->signer->sign('lookupserver', $dataArray, $user); $httpClient = $this->clientService->newClient(); try { - $httpClient->post($this->lookupServer, - [ - 'body' => json_encode($dataArray), - 'timeout' => 10, - 'connect_timeout' => 3, - ] - ); + 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, [ |