From: Joas Schilling Date: Fri, 11 Nov 2022 08:44:24 +0000 (+0100) Subject: Improve email search results X-Git-Tag: v26.0.0beta1~235^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fpull%2F35097%2Fhead;p=nextcloud-server.git Improve email search results Signed-off-by: Joas Schilling --- diff --git a/lib/private/Collaboration/Collaborators/MailPlugin.php b/lib/private/Collaboration/Collaborators/MailPlugin.php index d34d9fb0087..aa317ec1720 100644 --- a/lib/private/Collaboration/Collaborators/MailPlugin.php +++ b/lib/private/Collaboration/Collaborators/MailPlugin.php @@ -101,6 +101,12 @@ class MailPlugin implements ISearchPlugin { return false; } + // Extract the email address from "Foo Bar " and then search with "foo.bar@example.tld" instead + $result = preg_match('/<([^@]+@.+)>$/', $search, $matches); + if ($result && filter_var($matches[1], FILTER_VALIDATE_EMAIL)) { + return $this->search($matches[1], $limit, $offset, $searchResult); + } + $currentUserId = $this->userSession->getUser()->getUID(); $result = $userResults = ['wide' => [], 'exact' => []];