fs->getShareNode(); if ($share instanceof Folder) { $rootNode = $share; } else { $rootNode = Util::getUserFolder(); } try { $node = $rootNode->get($folder); } catch (\OCP\Files\NotFoundException) { 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. // // To top it off, all this is completely useless at the moment // because the MIME search is done PHP-side $rp = new \ReflectionProperty(\OC\Files\Node\Node::class, 'view'); $rp->setAccessible(true); /** @var \OC\Files\View */ $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())); // Construct root for the base folder. This way we can reuse the // root by filtering out the subfolders we don't want. $root = new TimelineRoot(); $this->fs->populateRoot($root); // Process to response type $list = array_map(function ($node) use ($root) { $root->addFolder($node); $root->baseChange($node->getPath()); return [ 'fileid' => $node->getId(), 'name' => $node->getName(), 'previews' => $this->tq->getRootPreviews($root), ]; }, $folders); return new Http\JSONResponse($list, Http::STATUS_OK); }); } }