From 2489a2d63a7b261e3362acd69af809fb242ad87c Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Thu, 4 May 2023 11:57:07 +0200 Subject: feat: specify media type via url path: systemtags-current/$mediaType - only the media part of the mime type can be search, but not the full mime type. It can be added, should it become necessary. - thus fixes previously hardcoded selector for image/ types - also fixes a return type hint - adds a return type hint Signed-off-by: Arthur Schiwon --- lib/private/Files/Node/Folder.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib/private/Files/Node') diff --git a/lib/private/Files/Node/Folder.php b/lib/private/Files/Node/Folder.php index e649e1efc28..2890ca6fcf6 100644 --- a/lib/private/Files/Node/Folder.php +++ b/lib/private/Files/Node/Folder.php @@ -338,10 +338,17 @@ class Folder extends Node implements \OCP\Files\Folder { } /** - * @return Node[] + * + * @return array */ public function getSystemTags(string $mediaType, int $limit = 0, int $offset = 0): array { - $query = $this->queryFromOperator(new SearchComparison(ISearchComparison::COMPARE_LIKE, 'mimetype', $mediaType . '/%'), null, $limit, $offset); + // Currently query has to have exactly one search condition. If no media type is provided, + // we fall back to the presence of a systemtag. + if (empty($mediaType)) { + $query = $this->queryFromOperator(new SearchComparison(ISearchComparison::COMPARE_LIKE, 'systemtag', '%'), null, $limit, $offset); + } else { + $query = $this->queryFromOperator(new SearchComparison(ISearchComparison::COMPARE_LIKE, 'mimetype', $mediaType . '/%'), null, $limit, $offset); + } [$caches, ] = $this->getCachesAndMountpointsForSearch(); /** @var QuerySearchHelper $searchHelper */ $searchHelper = \OCP\Server::get(QuerySearchHelper::class); -- cgit v1.2.3