summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBjoern Schiessle <bjoern@schiessle.org>2018-10-10 16:07:01 +0200
committerBjoern Schiessle <bjoern@schiessle.org>2018-10-10 16:08:49 +0200
commit84e39b522c41f2e638169034a9a65b35e847bc6f (patch)
tree370a5af7562c9b108e7ba88b0e8f46ddf744cadf /lib
parent7e608df5987e7158693bc4dd2ef81922cfbc6c0a (diff)
downloadnextcloud-server-84e39b522c41f2e638169034a9a65b35e847bc6f.tar.gz
nextcloud-server-84e39b522c41f2e638169034a9a65b35e847bc6f.zip
some small fixes and improvements
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Collaboration/Collaborators/LookupPlugin.php23
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/private/Collaboration/Collaborators/LookupPlugin.php b/lib/private/Collaboration/Collaborators/LookupPlugin.php
index 6f983b66b08..ae5f7fd0cbc 100644
--- a/lib/private/Collaboration/Collaborators/LookupPlugin.php
+++ b/lib/private/Collaboration/Collaborators/LookupPlugin.php
@@ -30,6 +30,7 @@ use OCP\Collaboration\Collaborators\SearchResultType;
use OCP\Federation\ICloudIdManager;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
+use OCP\ILogger;
use OCP\IUserSession;
use OCP\Share;
@@ -43,23 +44,27 @@ class LookupPlugin implements ISearchPlugin {
private $currentUserRemote;
/** @var ICloudIdManager */
private $cloudIdManager;
+ /** @var ILogger */
+ private $logger;
public function __construct(IConfig $config,
IClientService $clientService,
IUserSession $userSession,
- ICloudIdManager $cloudIdManager) {
+ ICloudIdManager $cloudIdManager,
+ ILogger $logger) {
$this->config = $config;
$this->clientService = $clientService;
$this->cloudIdManager = $cloudIdManager;
$currentUserCloudId = $userSession->getUser()->getCloudId();
$this->currentUserRemote = $cloudIdManager->resolveCloudId($currentUserCloudId)->getRemote();
+ $this->logger = $logger;
}
public function search($search, $limit, $offset, ISearchResult $searchResult) {
$isGlobalScaleEnabled = $this->config->getSystemValue('gs.enabled', false);
- $isLookupServerEnabled = $this->config->getAppValue('files_sharing', 'lookupServerEnabled', 'no');
+ $isLookupServerEnabled = $this->config->getAppValue('files_sharing', 'lookupServerEnabled', 'no') === 'yes';
// if case of Global Scale we always search the lookup server
- if ($isLookupServerEnabled !== 'yes' && !$isGlobalScaleEnabled) {
+ if (!$isLookupServerEnabled && !$isGlobalScaleEnabled) {
return false;
}
@@ -80,8 +85,16 @@ class LookupPlugin implements ISearchPlugin {
$body = json_decode($response->getBody(), true);
foreach ($body as $lookup) {
- $remote = $this->cloudIdManager->resolveCloudId($lookup['federationId'])->getRemote();
- if ($this->currentUserRemote === $remote) continue;
+ try {
+ $remote = $this->cloudIdManager->resolveCloudId($lookup['federationId'])->getRemote();
+ } catch (\Exception $e) {
+ $this->logger->error('Can not parse federated cloud ID "' . $lookup['federationId'] . '"');
+ $this->logger->error($e->getMessage());
+ continue;
+ }
+ if ($this->currentUserRemote === $remote) {
+ continue;
+ }
$name = isset($lookup['name']['value']) ? $lookup['name']['value'] : '';
$label = empty($name) ? $lookup['federationId'] : $name . ' (' . $lookup['federationId'] . ')';
$result[] = [