diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2023-05-04 11:57:07 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2023-05-16 12:46:50 +0200 |
commit | c0dbde5fba48be3b93e52087c4b7e5b59e6377ed (patch) | |
tree | a99bdf37303cf7fa6614cddca4af10a1e563306f /lib | |
parent | 2ea872d1562e77f486eb21323a2905b0585ea2f4 (diff) | |
download | nextcloud-server-c0dbde5fba48be3b93e52087c4b7e5b59e6377ed.tar.gz nextcloud-server-c0dbde5fba48be3b93e52087c4b7e5b59e6377ed.zip |
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 <blizzz@arthur-schiwon.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Files/Cache/QuerySearchHelper.php | 4 | ||||
-rw-r--r-- | lib/private/Files/Node/Folder.php | 11 |
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/private/Files/Cache/QuerySearchHelper.php b/lib/private/Files/Cache/QuerySearchHelper.php index c2eed5688b5..af198e9c832 100644 --- a/lib/private/Files/Cache/QuerySearchHelper.php +++ b/lib/private/Files/Cache/QuerySearchHelper.php @@ -97,6 +97,10 @@ class QuerySearchHelper { } } + + /** + * @return array<array-key, array{id: int, name: string, visibility: int, editable: int, ref_file_id: int, number_files: int}> + */ public function findUsedTagsInCaches(ISearchQuery $searchQuery, array $caches): array { $query = $this->getQueryBuilder(); $query->selectTagUsage(); diff --git a/lib/private/Files/Node/Folder.php b/lib/private/Files/Node/Folder.php index a34e1315385..15178758a51 100644 --- a/lib/private/Files/Node/Folder.php +++ b/lib/private/Files/Node/Folder.php @@ -337,10 +337,17 @@ class Folder extends Node implements \OCP\Files\Folder { } /** - * @return Node[] + * + * @return array<array-key, array{id: int, name: string, visibility: int, editable: int, ref_file_id: int, number_files: int}> */ 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); |