fix: Include email when searching share suggestions

Signed-off-by: nfebe <fenn25.fn@gmail.com>

[skip ci]
This commit is contained in:
nfebe 2025-09-17 13:20:25 +01:00 committed by F. E Noel Nfebe
parent 75179f9520
commit 26c452c6ee

View file

@ -41,7 +41,7 @@ class RemotePlugin implements ISearchPlugin {
$resultType = new SearchResultType('remotes');
// Search in contacts
$addressBookContacts = $this->contactsManager->search($search, ['CLOUD', 'FN'], [
$addressBookContacts = $this->contactsManager->search($search, ['CLOUD', 'FN', 'EMAIL'], [
'limit' => $limit,
'offset' => $offset,
'enumeration' => false,
@ -83,7 +83,17 @@ class RemotePlugin implements ISearchPlugin {
];
}
if (strtolower($contact['FN']) === $lowerSearch || strtolower($cloudId) === $lowerSearch) {
$emailMatch = false;
if (isset($contact['EMAIL'])) {
$emails = is_array($contact['EMAIL']) ? $contact['EMAIL'] : [$contact['EMAIL']];
foreach ($emails as $email) {
if (is_string($email) && strtolower($email) === $lowerSearch) {
$emailMatch = true;
break;
}
}
}
if ($emailMatch || strtolower($contact['FN']) === $lowerSearch || strtolower($cloudId) === $lowerSearch) {
if (strtolower($cloudId) === $lowerSearch) {
$searchResult->markExactIdMatch($resultType);
}