Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2021-12-08 19:26:30 +0300
committerJoas Schilling <coding@schilljs.com>2021-12-13 15:48:55 +0300
commit898c11c3b46ab746bf98174ba2f2bbf1f6ce2711 (patch)
treeea1742d3063a6e1b1ab77411529e5a3aaa1e3d48 /apps/files_sharing
parentdaad1ce0106421cd5e82a0705d0f39848be6e5ed (diff)
Limit more contact searches
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/lib/Activity/Providers/Base.php7
-rw-r--r--apps/files_sharing/lib/Controller/ShareAPIController.php8
-rw-r--r--apps/files_sharing/tests/Controller/ShareAPIControllerTest.php12
3 files changed, 22 insertions, 5 deletions
diff --git a/apps/files_sharing/lib/Activity/Providers/Base.php b/apps/files_sharing/lib/Activity/Providers/Base.php
index 948d629c8fc..e61bdffadcd 100644
--- a/apps/files_sharing/lib/Activity/Providers/Base.php
+++ b/apps/files_sharing/lib/Activity/Providers/Base.php
@@ -203,7 +203,12 @@ abstract class Base implements IProvider {
return $this->displayNames[$search];
}
- $addressBookContacts = $this->contactsManager->search($search, ['CLOUD']);
+ $addressBookContacts = $this->contactsManager->search($search, ['CLOUD'], [
+ 'limit' => 1,
+ 'enumeration' => false,
+ 'fullmatch' => false,
+ 'strict_search' => true,
+ ]);
foreach ($addressBookContacts as $contact) {
if (isset($contact['isLocalSystemBook'])) {
continue;
diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php
index c9853f1e12c..4d60a78ce95 100644
--- a/apps/files_sharing/lib/Controller/ShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareAPIController.php
@@ -334,8 +334,12 @@ class ShareAPIController extends OCSController {
* @return string
*/
private function getDisplayNameFromAddressBook(string $query, string $property): string {
- // FIXME: If we inject the contacts manager it gets initialized bofore any address books are registered
- $result = \OC::$server->getContactsManager()->search($query, [$property]);
+ // FIXME: If we inject the contacts manager it gets initialized before any address books are registered
+ $result = \OC::$server->getContactsManager()->search($query, [$property], [
+ 'limit' => 1,
+ 'enumeration' => false,
+ 'strict_search' => true,
+ ]);
foreach ($result as $r) {
foreach ($r[$property] as $value) {
if ($value === $query && $r['FN']) {
diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
index 86a7d479899..0a837400725 100644
--- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
@@ -4417,7 +4417,11 @@ class ShareAPIControllerTest extends TestCase {
$cm->method('search')
->willReturnMap([
- ['user@server.com', ['CLOUD'], [],
+ ['user@server.com', ['CLOUD'], [
+ 'limit' => 1,
+ 'enumeration' => false,
+ 'strict_search' => true,
+ ],
[
[
'CLOUD' => [
@@ -4427,7 +4431,11 @@ class ShareAPIControllerTest extends TestCase {
],
],
],
- ['user@server.com', ['EMAIL'], [],
+ ['user@server.com', ['EMAIL'], [
+ 'limit' => 1,
+ 'enumeration' => false,
+ 'strict_search' => true,
+ ],
[
[
'EMAIL' => [