summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2016-11-18 17:39:08 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2016-11-21 11:30:02 +0100
commit7b3855a3752053a440837fe0999e99cff7291dbc (patch)
tree463af9f9dad9ac28dcd1f98d257d9c5d2ae4950b /apps/files_sharing/lib
parentc49b0d383481a698b644187ff27cebdbee765444 (diff)
downloadnextcloud-server-7b3855a3752053a440837fe0999e99cff7291dbc.tar.gz
nextcloud-server-7b3855a3752053a440837fe0999e99cff7291dbc.zip
Add config switch
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Diffstat (limited to 'apps/files_sharing/lib')
-rw-r--r--apps/files_sharing/lib/Controller/ShareesAPIController.php42
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;
}