Use search for getting albums
parent
0e99d887d8
commit
d101a09137
|
@ -25,6 +25,8 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace OCA\Polaroid\Controller;
|
namespace OCA\Polaroid\Controller;
|
||||||
|
|
||||||
|
use OC\Files\Search\SearchComparison;
|
||||||
|
use OC\Files\Search\SearchQuery;
|
||||||
use OCA\Polaroid\AppInfo\Application;
|
use OCA\Polaroid\AppInfo\Application;
|
||||||
use OCP\AppFramework\Controller;
|
use OCP\AppFramework\Controller;
|
||||||
use OCP\AppFramework\Http;
|
use OCP\AppFramework\Http;
|
||||||
|
@ -36,6 +38,8 @@ use OCP\IConfig;
|
||||||
use OCP\IDBConnection;
|
use OCP\IDBConnection;
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
use OCP\IUserSession;
|
use OCP\IUserSession;
|
||||||
|
use OCP\Files\FileInfo;
|
||||||
|
use OCP\Files\Search\ISearchComparison;
|
||||||
|
|
||||||
class ApiController extends Controller {
|
class ApiController extends Controller {
|
||||||
private IConfig $config;
|
private IConfig $config;
|
||||||
|
@ -139,11 +143,15 @@ class ApiController extends Controller {
|
||||||
$list = $this->util->getDaysFolder($node->getId());
|
$list = $this->util->getDaysFolder($node->getId());
|
||||||
|
|
||||||
// Get subdirectories
|
// Get subdirectories
|
||||||
$sub = array_filter($node->getDirectoryListing(), function ($item) use ($node) {
|
$sub = $node->search(new SearchQuery(
|
||||||
return $item instanceof \OCP\Files\Folder;
|
new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'mimetype', FileInfo::MIMETYPE_FOLDER),
|
||||||
|
0, 0, [], $user));
|
||||||
|
$sub = array_filter($sub, function ($item) use ($node) {
|
||||||
|
return $item->getParent()->getId() === $node->getId();
|
||||||
});
|
});
|
||||||
// map sub to array of id
|
|
||||||
$subdir = [
|
// Map sub to JSON array
|
||||||
|
$subdirArray = [
|
||||||
"day_id" => -0.1,
|
"day_id" => -0.1,
|
||||||
"detail" => array_map(function ($item) {
|
"detail" => array_map(function ($item) {
|
||||||
return [
|
return [
|
||||||
|
@ -153,8 +161,8 @@ class ApiController extends Controller {
|
||||||
];
|
];
|
||||||
}, $sub, []),
|
}, $sub, []),
|
||||||
];
|
];
|
||||||
$subdir["count"] = count($subdir["detail"]);
|
$subdirArray["count"] = count($subdirArray["detail"]);
|
||||||
array_unshift($list, $subdir);
|
array_unshift($list, $subdirArray);
|
||||||
|
|
||||||
return new JSONResponse($list, Http::STATUS_OK);
|
return new JSONResponse($list, Http::STATUS_OK);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue