diff options
Diffstat (limited to 'apps/files_sharing/lib/Controller/ShareesAPIController.php')
-rw-r--r-- | apps/files_sharing/lib/Controller/ShareesAPIController.php | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareesAPIController.php b/apps/files_sharing/lib/Controller/ShareesAPIController.php index 7b9e10090d2..6b3208dc289 100644 --- a/apps/files_sharing/lib/Controller/ShareesAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareesAPIController.php @@ -626,22 +626,36 @@ class ShareesAPIController extends OCSController { } protected function getLookup($search) { - $client = $this->clientService->newClient(); - - $response = $client->get('https://lookup.nextcloud.com/users?search='.urlencode($search)); - $body = json_decode($response->getBody(), true); - + $isEnabled = $this->config->getAppValue('files_sharing', 'lookupServerEnabled', 'no'); $result = []; - foreach ($body as $lookup) { - $result[] = [ - 'label' => $lookup['federationId'], - 'value' => [ - 'shareType' => Share::SHARE_TYPE_REMOTE, - 'shareWith' => $lookup['federationId'], - ], - 'extra' => $lookup, - ]; + + if($isEnabled === 'yes') { + try { + $client = $this->clientService->newClient(); + $response = $client->get( + 'https://lookup.nextcloud.com/users?search=' . urlencode($search), + [ + 'timeout' => 10, + 'connect_timeout' => 3, + ] + ); + + $body = json_decode($response->getBody(), true); + + $result = []; + foreach ($body as $lookup) { + $result[] = [ + 'label' => $lookup['federationId'], + 'value' => [ + 'shareType' => Share::SHARE_TYPE_REMOTE, + 'shareWith' => $lookup['federationId'], + ], + 'extra' => $lookup, + ]; + } + } catch (\Exception $e) {} } + $this->result['lookup'] = $result; } |