mirror of
https://github.com/nextcloud/server.git
synced 2026-04-15 22:11:17 -04:00
Limit more contact searches
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
0f1670be8a
commit
d49ad7ea47
10 changed files with 65 additions and 13 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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']) {
|
||||
|
|
|
|||
|
|
@ -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' => [
|
||||
|
|
|
|||
|
|
@ -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'])) {
|
||||
|
|
|
|||
|
|
@ -67,7 +67,12 @@ class RemotePlugin implements ISearchPlugin {
|
|||
$resultType = new SearchResultType('remotes');
|
||||
|
||||
// Search in contacts
|
||||
$addressBookContacts = $this->contactsManager->search($search, ['CLOUD', 'FN'], ['limit' => $limit, 'offset' => $offset]);
|
||||
$addressBookContacts = $this->contactsManager->search($search, ['CLOUD', 'FN'], [
|
||||
'limit' => $limit,
|
||||
'offset' => $offset,
|
||||
'enumeration' => false,
|
||||
'fullmatch' => false,
|
||||
]);
|
||||
foreach ($addressBookContacts as $contact) {
|
||||
if (isset($contact['isLocalSystemBook'])) {
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -96,7 +96,10 @@ class ContactsStore implements IContactsStore {
|
|||
* @return IEntry[]
|
||||
*/
|
||||
public function getContacts(IUser $user, $filter, ?int $limit = null, ?int $offset = null) {
|
||||
$options = [];
|
||||
$options = [
|
||||
'enumeration' => $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') === 'yes',
|
||||
'fullmatch' => $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_full_match', 'yes') === 'yes',
|
||||
];
|
||||
if ($limit !== null) {
|
||||
$options['limit'] = $limit;
|
||||
}
|
||||
|
|
@ -270,7 +273,9 @@ class ContactsStore implements IContactsStore {
|
|||
return null;
|
||||
}
|
||||
|
||||
$contacts = $this->contactsManager->search($shareWith, $filter);
|
||||
$contacts = $this->contactsManager->search($shareWith, $filter, [
|
||||
'strict_search' => true,
|
||||
]);
|
||||
$match = null;
|
||||
|
||||
foreach ($contacts as $contact) {
|
||||
|
|
|
|||
|
|
@ -90,7 +90,12 @@ class CloudIdManager implements ICloudIdManager {
|
|||
}
|
||||
|
||||
protected function getDisplayNameFromContact(string $cloudId): ?string {
|
||||
$addressBookEntries = $this->contactsManager->search($cloudId, ['CLOUD']);
|
||||
$addressBookEntries = $this->contactsManager->search($cloudId, ['CLOUD'], [
|
||||
'limit' => 1,
|
||||
'enumeration' => false,
|
||||
'fullmatch' => false,
|
||||
'strict_search' => true,
|
||||
]);
|
||||
foreach ($addressBookEntries as $entry) {
|
||||
if (isset($entry['CLOUD'])) {
|
||||
foreach ($entry['CLOUD'] as $cloudID) {
|
||||
|
|
|
|||
|
|
@ -593,7 +593,12 @@ class Share extends Constants {
|
|||
$row['share_with_displayname'] = $shareWithUser === null ? $row['share_with'] : $shareWithUser->getDisplayName();
|
||||
} elseif (isset($row['share_with']) && $row['share_with'] != '' &&
|
||||
$row['share_type'] === IShare::TYPE_REMOTE) {
|
||||
$addressBookEntries = \OC::$server->getContactsManager()->search($row['share_with'], ['CLOUD']);
|
||||
$addressBookEntries = \OC::$server->getContactsManager()->search($row['share_with'], ['CLOUD'], [
|
||||
'limit' => 1,
|
||||
'enumeration' => false,
|
||||
'fullmatch' => false,
|
||||
'strict_search' => true,
|
||||
]);
|
||||
foreach ($addressBookEntries as $entry) {
|
||||
foreach ($entry['CLOUD'] as $cloudID) {
|
||||
if ($cloudID === $row['share_with']) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue