Skip to content

Commit

Permalink
Merge pull request #10919 from nextcloud/bugfix/noid/use-OCP-constant…
Browse files Browse the repository at this point in the history
…s-for-filters

fix(search): Use OCP constants for filters
  • Loading branch information
nickvergessen authored Nov 17, 2023
2 parents 07dcc76 + 1ceb3ee commit 6fdfabb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
8 changes: 4 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions lib/Search/MessageSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\Search\IFilter;
use OCP\Search\IFilteringProvider;
use OCP\Search\IProvider;
use OCP\Search\ISearchQuery;
Expand Down Expand Up @@ -140,19 +141,19 @@ public function performSearch(IUser $user, ISearchQuery $query, string $title, a

// Apply filters when available
$lowerTimeBoundary = $upperTimeBoundary = $actorType = $actorId = null;
if ($since = $query->getFilter('since')?->get()) {
if ($since = $query->getFilter(IFilter::BUILTIN_SINCE)?->get()) {
if ($since instanceof \DateTimeImmutable) {
$lowerTimeBoundary = $since;
}
}

if ($until = $query->getFilter('until')?->get()) {
if ($until = $query->getFilter(IFilter::BUILTIN_UNTIL)?->get()) {
if ($until instanceof \DateTimeImmutable) {
$upperTimeBoundary = $until;
}
}

if ($person = $query->getFilter('person')?->get()) {
if ($person = $query->getFilter(IFilter::BUILTIN_PERSON)?->get()) {
if ($person instanceof IUser) {
$actorType = Attendee::ACTOR_USERS;
$actorId = $person->getUID();
Expand Down Expand Up @@ -271,10 +272,10 @@ protected function commentToSearchResultEntry(Room $room, IUser $user, IComment

public function getSupportedFilters(): array {
return [
'term',
'since',
'until',
'person',
IFilter::BUILTIN_TERM,
IFilter::BUILTIN_SINCE,
IFilter::BUILTIN_UNTIL,
IFilter::BUILTIN_PERSON,
];
}

Expand Down

0 comments on commit 6fdfabb

Please sign in to comment.