From 25659255d76c9c61e861a414b6fc94aca5d113ff Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Fri, 22 Nov 2024 09:25:05 +0100 Subject: [PATCH] fix(contactsintegration): Limit number of matches Signed-off-by: Christoph Wurst --- lib/Service/ContactsIntegration.php | 10 +++++++++- tests/Unit/Service/ContactsIntegrationTest.php | 11 ++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/Service/ContactsIntegration.php b/lib/Service/ContactsIntegration.php index da53a72b88..4a976b452d 100644 --- a/lib/Service/ContactsIntegration.php +++ b/lib/Service/ContactsIntegration.php @@ -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 []; } diff --git a/tests/Unit/Service/ContactsIntegrationTest.php b/tests/Unit/Service/ContactsIntegrationTest.php index c0dc3b57af..fdfa6f8a5c 100644 --- a/tests/Unit/Service/ContactsIntegrationTest.php +++ b/tests/Unit/Service/ContactsIntegrationTest.php @@ -1,5 +1,7 @@ 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)); }