get($folder); } catch (\OCP\Files\NotFoundException $e) { throw Exceptions::NotFound('Folder not found'); } if (!$node instanceof Folder) { throw Exceptions::NotFound('Path is not a folder'); } // Ugly: get the view of the folder with reflection // This is unfortunately the only way to get the contents of a folder // matching a MIME type without using SEARCH, which is deep $rp = new \ReflectionProperty('\OC\Files\Node\Node', 'view'); $rp->setAccessible(true); $view = $rp->getValue($node); // Get the subfolders $folders = $view->getDirectoryContent($node->getPath(), FileInfo::MIMETYPE_FOLDER, $node); // Sort by name usort($folders, static fn ($a, $b) => strnatcmp($a->getName(), $b->getName())); // Process to response type $list = array_map(fn ($node) => [ 'fileid' => $node->getId(), 'name' => $node->getName(), 'path' => $node->getPath(), 'previews' => $this->timelineQuery->getFolderPreviews($node), ], $folders); return new Http\JSONResponse($list, Http::STATUS_OK); }); } }