Passed
Push — master ( ff0ccc...d70d90 )
by Maxence
15:36 queued 11s
created
lib/private/Collaboration/Collaborators/LookupPlugin.php 1 patch
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -39,89 +39,89 @@
 block discarded – undo
39 39
 
40 40
 class LookupPlugin implements ISearchPlugin {
41 41
 
42
-	/** @var IConfig */
43
-	private $config;
44
-	/** @var IClientService */
45
-	private $clientService;
46
-	/** @var string remote part of the current user's cloud id */
47
-	private $currentUserRemote;
48
-	/** @var ICloudIdManager */
49
-	private $cloudIdManager;
50
-	/** @var LoggerInterface */
51
-	private $logger;
42
+    /** @var IConfig */
43
+    private $config;
44
+    /** @var IClientService */
45
+    private $clientService;
46
+    /** @var string remote part of the current user's cloud id */
47
+    private $currentUserRemote;
48
+    /** @var ICloudIdManager */
49
+    private $cloudIdManager;
50
+    /** @var LoggerInterface */
51
+    private $logger;
52 52
 
53
-	public function __construct(IConfig $config,
54
-								IClientService $clientService,
55
-								IUserSession $userSession,
56
-								ICloudIdManager $cloudIdManager,
57
-								LoggerInterface $logger) {
58
-		$this->config = $config;
59
-		$this->clientService = $clientService;
60
-		$this->cloudIdManager = $cloudIdManager;
61
-		$currentUserCloudId = $userSession->getUser()->getCloudId();
62
-		$this->currentUserRemote = $cloudIdManager->resolveCloudId($currentUserCloudId)->getRemote();
63
-		$this->logger = $logger;
64
-	}
53
+    public function __construct(IConfig $config,
54
+                                IClientService $clientService,
55
+                                IUserSession $userSession,
56
+                                ICloudIdManager $cloudIdManager,
57
+                                LoggerInterface $logger) {
58
+        $this->config = $config;
59
+        $this->clientService = $clientService;
60
+        $this->cloudIdManager = $cloudIdManager;
61
+        $currentUserCloudId = $userSession->getUser()->getCloudId();
62
+        $this->currentUserRemote = $cloudIdManager->resolveCloudId($currentUserCloudId)->getRemote();
63
+        $this->logger = $logger;
64
+    }
65 65
 
66
-	public function search($search, $limit, $offset, ISearchResult $searchResult) {
67
-		$isGlobalScaleEnabled = $this->config->getSystemValue('gs.enabled', false);
68
-		$isLookupServerEnabled = $this->config->getAppValue('files_sharing', 'lookupServerEnabled', 'yes') === 'yes';
69
-		$hasInternetConnection = $this->config->getSystemValueBool('has_internet_connection', true);
66
+    public function search($search, $limit, $offset, ISearchResult $searchResult) {
67
+        $isGlobalScaleEnabled = $this->config->getSystemValue('gs.enabled', false);
68
+        $isLookupServerEnabled = $this->config->getAppValue('files_sharing', 'lookupServerEnabled', 'yes') === 'yes';
69
+        $hasInternetConnection = $this->config->getSystemValueBool('has_internet_connection', true);
70 70
 
71
-		// if case of Global Scale we always search the lookup server
72
-		if (!$isGlobalScaleEnabled && (!$isLookupServerEnabled || !$hasInternetConnection)) {
73
-			return false;
74
-		}
71
+        // if case of Global Scale we always search the lookup server
72
+        if (!$isGlobalScaleEnabled && (!$isLookupServerEnabled || !$hasInternetConnection)) {
73
+            return false;
74
+        }
75 75
 
76
-		$lookupServerUrl = $this->config->getSystemValue('lookup_server', 'https://lookup.nextcloud.com');
77
-		if (empty($lookupServerUrl)) {
78
-			return false;
79
-		}
80
-		$lookupServerUrl = rtrim($lookupServerUrl, '/');
81
-		$result = [];
76
+        $lookupServerUrl = $this->config->getSystemValue('lookup_server', 'https://lookup.nextcloud.com');
77
+        if (empty($lookupServerUrl)) {
78
+            return false;
79
+        }
80
+        $lookupServerUrl = rtrim($lookupServerUrl, '/');
81
+        $result = [];
82 82
 
83
-		try {
84
-			$client = $this->clientService->newClient();
85
-			$response = $client->get(
86
-				$lookupServerUrl . '/users?search=' . urlencode($search),
87
-				[
88
-					'timeout' => 10,
89
-					'connect_timeout' => 3,
90
-				]
91
-			);
83
+        try {
84
+            $client = $this->clientService->newClient();
85
+            $response = $client->get(
86
+                $lookupServerUrl . '/users?search=' . urlencode($search),
87
+                [
88
+                    'timeout' => 10,
89
+                    'connect_timeout' => 3,
90
+                ]
91
+            );
92 92
 
93
-			$body = json_decode($response->getBody(), true);
93
+            $body = json_decode($response->getBody(), true);
94 94
 
95
-			foreach ($body as $lookup) {
96
-				try {
97
-					$remote = $this->cloudIdManager->resolveCloudId($lookup['federationId'])->getRemote();
98
-				} catch (\Exception $e) {
99
-					$this->logger->error('Can not parse federated cloud ID "' .  $lookup['federationId'] . '"', [
100
-						'exception' => $e,
101
-					]);
102
-					continue;
103
-				}
104
-				if ($this->currentUserRemote === $remote) {
105
-					continue;
106
-				}
107
-				$name = isset($lookup['name']['value']) ? $lookup['name']['value'] : '';
108
-				$label = empty($name) ? $lookup['federationId'] : $name . ' (' . $lookup['federationId'] . ')';
109
-				$result[] = [
110
-					'label' => $label,
111
-					'value' => [
112
-						'shareType' => IShare::TYPE_REMOTE,
113
-						'globalScale' => $isGlobalScaleEnabled,
114
-						'shareWith' => $lookup['federationId'],
115
-					],
116
-					'extra' => $lookup,
117
-				];
118
-			}
119
-		} catch (\Exception $e) {
120
-		}
95
+            foreach ($body as $lookup) {
96
+                try {
97
+                    $remote = $this->cloudIdManager->resolveCloudId($lookup['federationId'])->getRemote();
98
+                } catch (\Exception $e) {
99
+                    $this->logger->error('Can not parse federated cloud ID "' .  $lookup['federationId'] . '"', [
100
+                        'exception' => $e,
101
+                    ]);
102
+                    continue;
103
+                }
104
+                if ($this->currentUserRemote === $remote) {
105
+                    continue;
106
+                }
107
+                $name = isset($lookup['name']['value']) ? $lookup['name']['value'] : '';
108
+                $label = empty($name) ? $lookup['federationId'] : $name . ' (' . $lookup['federationId'] . ')';
109
+                $result[] = [
110
+                    'label' => $label,
111
+                    'value' => [
112
+                        'shareType' => IShare::TYPE_REMOTE,
113
+                        'globalScale' => $isGlobalScaleEnabled,
114
+                        'shareWith' => $lookup['federationId'],
115
+                    ],
116
+                    'extra' => $lookup,
117
+                ];
118
+            }
119
+        } catch (\Exception $e) {
120
+        }
121 121
 
122
-		$type = new SearchResultType('lookup');
123
-		$searchResult->addResultSet($type, $result, []);
122
+        $type = new SearchResultType('lookup');
123
+        $searchResult->addResultSet($type, $result, []);
124 124
 
125
-		return false;
126
-	}
125
+        return false;
126
+    }
127 127
 }
Please login to merge, or discard this patch.