feat(search): allow contacts person search

Signed-off-by: hamza221 <hamzamahjoubi221@gmail.com>
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
pull/41457/head
hamza221 2023-11-14 14:09:12 +07:00 committed by Christoph Wurst
parent 8b5d85a953
commit 26ee5a531b
No known key found for this signature in database
GPG Key ID: CC42AC2A7F0E56D8
2 changed files with 13 additions and 1 deletions

@ -1118,6 +1118,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
* wildcard?: bool,
* since?: DateTimeFilter|null,
* until?: DateTimeFilter|null,
* person?: string
* } $options
* @return array
*/
@ -1182,6 +1183,9 @@ class CardDavBackend implements BackendInterface, SyncSupport {
$query2->setFirstResult($options['offset']);
}
if (isset($options['person'])) {
$query2->andWhere($query2->expr()->ilike('cp.value', $query2->createNamedParameter('%' . $this->db->escapeLikeParameter($options['person']) . '%')));
}
if (isset($options['since']) || isset($options['until'])) {
$query2->join('cp', $this->dbCardsPropertiesTable, 'cp_bday', 'cp.cardid = cp_bday.cardid');
$query2->andWhere($query2->expr()->eq('cp_bday.name', $query2->createNamedParameter('BDAY')));

@ -33,6 +33,7 @@ use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\Search\FilterDefinition;
use OCP\Search\IFilter;
use OCP\Search\IFilteringProvider;
use OCP\Search\ISearchQuery;
use OCP\Search\SearchResult;
@ -110,7 +111,7 @@ class ContactsSearchProvider implements IFilteringProvider {
'offset' => $query->getCursor(),
'since' => $query->getFilter('since'),
'until' => $query->getFilter('until'),
'person' => $query->getFilter('person'),
'person' => $this->getPersonDisplayName($query->getFilter('person')),
'company' => $query->getFilter('company'),
],
);
@ -137,6 +138,13 @@ class ContactsSearchProvider implements IFilteringProvider {
$query->getCursor() + count($formattedResults)
);
}
private function getPersonDisplayName(?IFilter $person): ?string {
$user = $person?->get();
if ($user instanceof IUser) {
return $user->getDisplayName();
}
return null;
}
protected function getDavUrlForContact(
string $principalUri,