Skip to content

Commit fc02a8a

Browse files
Merge pull request #3416 from nextcloud/backport/3415/stable30
2 parents 89a7c44 + ffc9d8d commit fc02a8a

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

β€Žlib/Controller/FolderController.php

+7-4
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private function formatFolder(array $folder): array {
100100
* Gets all Groupfolders
101101
* @NoAdminRequired
102102
* @param bool $applicable Filter by applicable groups
103-
* @return DataResponse<Http::STATUS_OK, list<GroupFoldersFolder>, array{}>
103+
* @return DataResponse<Http::STATUS_OK, array<string, GroupFoldersFolder>, array{}>
104104
* @throws OCSNotFoundException Storage not found
105105
*
106106
* 200: Groupfolders returned
@@ -111,8 +111,11 @@ public function getFolders(bool $applicable = false): DataResponse {
111111
throw new OCSNotFoundException();
112112
}
113113

114-
$folders = array_values($this->manager->getAllFoldersWithSize($storageId));
115-
$folders = array_map($this->formatFolder(...), $folders);
114+
$folders = [];
115+
foreach ($this->manager->getAllFoldersWithSize($storageId) as $id => $folder) {
116+
// Make them string-indexed for OpenAPI JSON output
117+
$folders[(string)$id] = $this->formatFolder($folder);
118+
}
116119
$isAdmin = $this->delegationService->isAdminNextcloud() || $this->delegationService->isDelegatedAdmin();
117120
if ($isAdmin && !$applicable) {
118121
return new DataResponse($folders);
@@ -121,7 +124,7 @@ public function getFolders(bool $applicable = false): DataResponse {
121124
$folders = $this->foldersFilter->getForApiUser($folders);
122125
}
123126
if ($applicable || !$this->delegationService->hasApiAccess()) {
124-
$folders = array_values(array_filter(array_map($this->filterNonAdminFolder(...), $folders)));
127+
$folders = array_filter(array_map($this->filterNonAdminFolder(...), $folders));
125128
}
126129
return new DataResponse($folders);
127130
}

β€Žlib/Service/FoldersFilter.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public function __construct(IUserSession $userSession, IGroupManager $groupManag
2424
}
2525

2626
/**
27-
* @param list<GroupFoldersFolder> $folders List of all folders
28-
* @return list<GroupFoldersFolder>
27+
* @param GroupFoldersFolder[] $folders List of all folders
28+
* @return GroupFoldersFolder[]
2929
*/
3030
public function getForApiUser(array $folders): array {
3131
$user = $this->userSession->getUser();

β€Žopenapi.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@
248248
"content": {
249249
"application/json": {
250250
"schema": {
251-
"type": "array",
252-
"items": {
251+
"type": "object",
252+
"additionalProperties": {
253253
"$ref": "#/components/schemas/Folder"
254254
}
255255
}

β€Žsrc/types/openapi/openapi.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,9 @@ export interface operations {
328328
[name: string]: unknown;
329329
};
330330
content: {
331-
"application/json": components["schemas"]["Folder"][];
331+
"application/json": {
332+
[key: string]: components["schemas"]["Folder"];
333+
};
332334
};
333335
};
334336
/** @description Storage not found */

0 commit comments

Comments
Β (0)