diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2020-07-30 12:50:04 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2020-07-31 12:42:17 +0200 |
commit | 7c56283c3ccb8f6d6ca6eeefd44a3db15d134da2 (patch) | |
tree | 8c54fc760c509f26ddd67d265d115387cd20ae04 /lib/private/Contacts/ContactsMenu/ContactsStore.php | |
parent | a32e6a795868f4d26983b26502d2588b3e6fd80e (diff) | |
download | nextcloud-server-7c56283c3ccb8f6d6ca6eeefd44a3db15d134da2.tar.gz nextcloud-server-7c56283c3ccb8f6d6ca6eeefd44a3db15d134da2.zip |
contactsmanager shall limit number of results early
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'lib/private/Contacts/ContactsMenu/ContactsStore.php')
-rw-r--r-- | lib/private/Contacts/ContactsMenu/ContactsStore.php | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/lib/private/Contacts/ContactsMenu/ContactsStore.php b/lib/private/Contacts/ContactsMenu/ContactsStore.php index b0bd99b844e..81c4f5d6baf 100644 --- a/lib/private/Contacts/ContactsMenu/ContactsStore.php +++ b/lib/private/Contacts/ContactsMenu/ContactsStore.php @@ -73,11 +73,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); @@ -122,7 +134,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 |