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/lib
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2020-07-30 13:50:04 +0300
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2020-10-13 18:45:02 +0300
commitfb39aec4fde9415e93b9919d72d5d7b66796dead (patch)
tree0b69012c2f01a66a2ffeaea302b056329f959d8c /lib
parenta79a6d5f345b9375cf962bc4f57438ffe1e39a5d (diff)
contactsmanager shall limit number of results early
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Contacts/ContactsMenu/ContactsStore.php24
-rw-r--r--lib/private/Contacts/ContactsMenu/Manager.php2
-rw-r--r--lib/public/Contacts/ContactsMenu/IContactsStore.php6
3 files changed, 23 insertions, 9 deletions
diff --git a/lib/private/Contacts/ContactsMenu/ContactsStore.php b/lib/private/Contacts/ContactsMenu/ContactsStore.php
index b6e401cbe71..267cc5519e3 100644
--- a/lib/private/Contacts/ContactsMenu/ContactsStore.php
+++ b/lib/private/Contacts/ContactsMenu/ContactsStore.php
@@ -71,11 +71,23 @@ class ContactsStore implements IContactsStore {
* @param string|null $filter
* @return IEntry[]
*/
- public function getContacts(IUser $user, $filter) {
- $allContacts = $this->contactsManager->search($filter ?: '', [
- 'FN',
- 'EMAIL'
- ]);
+ public function getContacts(IUser $user, $filter, ?int $limit = null, ?int $offset = null) {
+ $options = [];
+ if ($limit !== null) {
+ $options['limit'] = $limit;
+ }
+ if ($offset !== null) {
+ $options['offset'] = $offset;
+ }
+
+ $allContacts = $this->contactsManager->search(
+ $filter ?: '',
+ [
+ 'FN',
+ 'EMAIL'
+ ],
+ $options
+ );
$entries = array_map(function(array $contact) {
return $this->contactArrayToEntry($contact);
@@ -119,7 +131,7 @@ class ContactsStore implements IContactsStore {
if ($excludedGroups) {
$excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', '');
$decodedExcludeGroups = json_decode($excludedGroups, true);
- $excludeGroupsList = ($decodedExcludeGroups !== null) ? $decodedExcludeGroups : [];
+ $excludeGroupsList = ($decodedExcludeGroups !== null) ? $decodedExcludeGroups : [];
if (count(array_intersect($excludeGroupsList, $selfGroups)) !== 0) {
// a group of the current user is excluded -> filter all local users
diff --git a/lib/private/Contacts/ContactsMenu/Manager.php b/lib/private/Contacts/ContactsMenu/Manager.php
index 0ebc9648285..48603320925 100644
--- a/lib/private/Contacts/ContactsMenu/Manager.php
+++ b/lib/private/Contacts/ContactsMenu/Manager.php
@@ -66,7 +66,7 @@ class Manager {
$minSearchStringLength = $this->config->getSystemValueInt('sharing.minSearchStringLength', 0);
$topEntries = [];
if (strlen($filter) >= $minSearchStringLength) {
- $entries = $this->store->getContacts($user, $filter);
+ $entries = $this->store->getContacts($user, $filter, $maxAutocompleteResults);
$sortedEntries = $this->sortEntries($entries);
$topEntries = array_slice($sortedEntries, 0, $maxAutocompleteResults);
diff --git a/lib/public/Contacts/ContactsMenu/IContactsStore.php b/lib/public/Contacts/ContactsMenu/IContactsStore.php
index 76d0f76a933..9aa99a363e9 100644
--- a/lib/public/Contacts/ContactsMenu/IContactsStore.php
+++ b/lib/public/Contacts/ContactsMenu/IContactsStore.php
@@ -33,11 +33,13 @@ interface IContactsStore {
/**
* @param IUser $user
- * @param $filter
+ * @param string $filter
+ * @param int $limit added 19.0.2
+ * @param int $offset added 19.0.2
* @return IEntry[]
* @since 13.0.0
*/
- public function getContacts(IUser $user, $filter);
+ public function getContacts(IUser $user, $filter, ?int $limit = null, ?int $offset = null);
/**
* @brief finds a contact by specifying the property to search on ($shareType) and the value ($shareWith)