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
path: root/apps
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
parentdaad1ce0106421cd5e82a0705d0f39848be6e5ed (diff)
Limit more contact searches
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/federatedfilesharing/lib/Notifier.php7
-rw-r--r--apps/files/lib/Activity/Provider.php7
-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
-rw-r--r--apps/sharebymail/lib/Activity.php7
6 files changed, 40 insertions, 8 deletions
diff --git a/apps/federatedfilesharing/lib/Notifier.php b/apps/federatedfilesharing/lib/Notifier.php
index fa0119010cf..5e57b77b64a 100644
--- a/apps/federatedfilesharing/lib/Notifier.php
+++ b/apps/federatedfilesharing/lib/Notifier.php
@@ -255,7 +255,12 @@ class Notifier implements INotifier {
}
}
- $addressBookEntries = $this->contactsManager->search($federatedCloudId, ['CLOUD']);
+ $addressBookEntries = $this->contactsManager->search($federatedCloudId, ['CLOUD'], [
+ 'limit' => 1,
+ 'enumeration' => false,
+ 'fullmatch' => false,
+ 'strict_search' => true,
+ ]);
foreach ($addressBookEntries as $entry) {
if (isset($entry['CLOUD'])) {
foreach ($entry['CLOUD'] as $cloudID) {
diff --git a/apps/files/lib/Activity/Provider.php b/apps/files/lib/Activity/Provider.php
index 8f3a5a4f417..a7db85a0de1 100644
--- a/apps/files/lib/Activity/Provider.php
+++ b/apps/files/lib/Activity/Provider.php
@@ -560,7 +560,12 @@ class Provider 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/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' => [
diff --git a/apps/sharebymail/lib/Activity.php b/apps/sharebymail/lib/Activity.php
index ff012654834..3992f0f942b 100644
--- a/apps/sharebymail/lib/Activity.php
+++ b/apps/sharebymail/lib/Activity.php
@@ -362,7 +362,12 @@ class Activity implements IProvider {
* @return string
*/
protected function getContactName($email) {
- $addressBookContacts = $this->contactsManager->search($email, ['EMAIL']);
+ $addressBookContacts = $this->contactsManager->search($email, ['EMAIL'], [
+ 'limit' => 1,
+ 'enumeration' => false,
+ 'fullmatch' => false,
+ 'strict_search' => true,
+ ]);
foreach ($addressBookContacts as $contact) {
if (isset($contact['isLocalSystemBook'])) {