Skip to content

Commit

Permalink
fix(contactsintegration): Limit number of matches
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Wurst <[email protected]>
  • Loading branch information
ChristophWurst committed Dec 9, 2024
1 parent 2d6ef2f commit ada36b8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
10 changes: 9 additions & 1 deletion lib/Service/ContactsIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,15 @@ public function getMatchingRecipient(string $userId, string $term): array {
$shareeEnumerationFullMatchUserId = $shareeEnumerationFullMatch && $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_full_match_userid', 'yes') === 'yes';
$shareeEnumerationFullMatchEmail = $shareeEnumerationFullMatch && $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_full_match_email', 'yes') === 'yes';

$result = $this->contactsManager->search($term, ['UID', 'FN', 'EMAIL'], ['enumeration' => $shareeEnumeration, 'fullmatch' => $shareeEnumerationFullMatch]);
$result = $this->contactsManager->search(
$term,
['UID', 'FN', 'EMAIL'],
[
'enumeration' => $shareeEnumeration,
'fullmatch' => $shareeEnumerationFullMatch,
'limit' => 20,
],
);
if (empty($result)) {
return [];
}
Expand Down
11 changes: 10 additions & 1 deletion tests/Unit/Service/ContactsIntegrationTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2015-2016 ownCloud, Inc.
Expand Down Expand Up @@ -353,7 +355,14 @@ public function common($term, $searchResult, $allowSystemUsers, $allowSystemUser
->will($this->returnValue(true));
$this->contactsManager->expects($this->once())
->method('search')
->with($term, ['UID', 'FN', 'EMAIL'], ['enumeration' => $allowSystemUsers, 'fullmatch' => $shareeEnumerationFullMatch])
->with(
$term,
['UID', 'FN', 'EMAIL'],
[
'enumeration' => $allowSystemUsers,
'fullmatch' => $shareeEnumerationFullMatch,
'limit' => 20,
])
->will($this->returnValue($searchResult));
}

Expand Down

0 comments on commit ada36b8

Please sign in to comment.