Make sure to only add system users once
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
ae693129db
commit
4f98852f52
|
@ -607,10 +607,11 @@ class ShareesAPIController extends OCSController {
|
||||||
}
|
}
|
||||||
foreach ($emailAddresses as $emailAddress) {
|
foreach ($emailAddresses as $emailAddress) {
|
||||||
$exactEmailMatch = strtolower($emailAddress) === $lowerSearch;
|
$exactEmailMatch = strtolower($emailAddress) === $lowerSearch;
|
||||||
if ($exactEmailMatch || strtolower($contact['FN']) === $lowerSearch) {
|
|
||||||
if (isset($contact['isLocalSystemBook'])) {
|
if (isset($contact['isLocalSystemBook'])) {
|
||||||
if ($exactEmailMatch) {
|
if ($exactEmailMatch) {
|
||||||
$cloud = $this->cloudIdManager->resolveCloudId($contact['CLOUD'][0]);
|
$cloud = $this->cloudIdManager->resolveCloudId($contact['CLOUD'][0]);
|
||||||
|
if (!$this->hasUserInResult($cloud->getUser())) {
|
||||||
$this->result['exact']['users'][] = [
|
$this->result['exact']['users'][] = [
|
||||||
'label' => $contact['FN'] . " ($emailAddress)",
|
'label' => $contact['FN'] . " ($emailAddress)",
|
||||||
'value' => [
|
'value' => [
|
||||||
|
@ -618,10 +619,12 @@ class ShareesAPIController extends OCSController {
|
||||||
'shareWith' => $cloud->getUser(),
|
'shareWith' => $cloud->getUser(),
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
return ['results' => [], 'exact' => [], 'exactIdMatch' => true];
|
|
||||||
}
|
}
|
||||||
if ($this->shareeEnumeration) {
|
return ['results' => [], 'exact' => [], 'exactIdMatch' => true];
|
||||||
$cloud = $this->cloudIdManager->resolveCloudId($contact['CLOUD'][0]);
|
}
|
||||||
|
if ($this->shareeEnumeration) {
|
||||||
|
$cloud = $this->cloudIdManager->resolveCloudId($contact['CLOUD'][0]);
|
||||||
|
if (!$this->hasUserInResult($cloud->getUser())) {
|
||||||
$this->result['users'][] = [
|
$this->result['users'][] = [
|
||||||
'label' => $contact['FN'] . " ($emailAddress)",
|
'label' => $contact['FN'] . " ($emailAddress)",
|
||||||
'value' => [
|
'value' => [
|
||||||
|
@ -630,9 +633,11 @@ class ShareesAPIController extends OCSController {
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($exactEmailMatch || strtolower($contact['FN']) === $lowerSearch) {
|
||||||
if ($exactEmailMatch) {
|
if ($exactEmailMatch) {
|
||||||
$result['exactIdMatch'] = true;
|
$result['exactIdMatch'] = true;
|
||||||
}
|
}
|
||||||
|
@ -711,6 +716,28 @@ class ShareesAPIController extends OCSController {
|
||||||
$this->result['lookup'] = $result;
|
$this->result['lookup'] = $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a given user is already part of the result
|
||||||
|
*
|
||||||
|
* @param string $userId
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function hasUserInResult($userId) {
|
||||||
|
foreach ($this->result['exact']['users'] as $result) {
|
||||||
|
if ($result['value']['shareWith'] === $userId) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($this->result['users'] as $result) {
|
||||||
|
if ($result['value']['shareWith'] === $userId) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a bunch of pagination links for the current page
|
* Generates a bunch of pagination links for the current page
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue