Skip to content

Commit

Permalink
OCS API Returns updated groupfolder data after modifications
Browse files Browse the repository at this point in the history
Resolves #3665

Signed-off-by: Aaron Segura <aaron@aaronsegura.com>
  • Loading branch information
aaronsegura committed Mar 4, 2025
1 parent 063399b commit 66ae8bc
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 25 deletions.
42 changes: 25 additions & 17 deletions lib/Controller/FolderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ public function getFolder(int $id): DataResponse {
throw new OCSNotFoundException();
}
}

return new DataResponse($folder);
}

Expand Down Expand Up @@ -244,7 +243,7 @@ public function removeFolder(int $id): DataResponse {
*
* @param int $id ID of the Groupfolder
* @param string $mountPoint New mount point path
* @return DataResponse<Http::STATUS_OK, array{success: true}, array{}>
* @return DataResponse<Http::STATUS_OK, array{success: true, folder: GroupFoldersFolder}, array{}>
*
* 200: Mount point changed successfully
*/
Expand All @@ -254,15 +253,17 @@ public function removeFolder(int $id): DataResponse {
#[FrontpageRoute(verb: 'PUT', url: '/folders/{id}')]
public function setMountPoint(int $id, string $mountPoint): DataResponse {
$this->manager->renameFolder($id, trim($mountPoint));
return new DataResponse(['success' => true]);

$folder = $this->getFolder($id);
return new DataResponse(['success' => true, 'folder' => $folder->getData()]);
}

/**
* Add access of a group for a Groupfolder
*
* @param int $id ID of the Groupfolder
* @param string $group Group to add access for
* @return DataResponse<Http::STATUS_OK, array{success: true}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, list<empty>, array{}>
* @return DataResponse<Http::STATUS_OK, array{success: true, folder: GroupFoldersFolder}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, list<empty>, array{}>
*
* 200: Group access added successfully
* 404: Groupfolder not found
Expand All @@ -279,15 +280,16 @@ public function addGroup(int $id, string $group): DataResponse {

$this->manager->addApplicableGroup($id, $group);

return new DataResponse(['success' => true]);
$folder = $this->getFolder($id);
return new DataResponse(['success' => true, 'folder' => $folder->getData()]);
}

/**
* Remove access of a group from a Groupfolder
*
* @param int $id ID of the Groupfolder
* @param string $group Group to remove access from
* @return DataResponse<Http::STATUS_OK, array{success: true}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, list<empty>, array{}>
* @return DataResponse<Http::STATUS_OK, array{success: true, folder: GroupFoldersFolder}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, list<empty>, array{}>
*
* 200: Group access removed successfully
* 404: Groupfolder not found
Expand All @@ -304,7 +306,8 @@ public function removeGroup(int $id, string $group): DataResponse {

$this->manager->removeApplicableGroup($id, $group);

return new DataResponse(['success' => true]);
$folder = $this->getFolder($id);
return new DataResponse(['success' => true, 'folder' => $folder->getData()]);
}

/**
Expand All @@ -313,7 +316,7 @@ public function removeGroup(int $id, string $group): DataResponse {
* @param int $id ID of the Groupfolder
* @param string $group Group for which the permissions will be set
* @param int $permissions New permissions
* @return DataResponse<Http::STATUS_OK, array{success: true}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, list<empty>, array{}>
* @return DataResponse<Http::STATUS_OK, array{success: true, folder: GroupFoldersFolder}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, list<empty>, array{}>
*
* 200: Permissions updated successfully
* 404: Groupfolder not found
Expand All @@ -330,7 +333,8 @@ public function setPermissions(int $id, string $group, int $permissions): DataRe

$this->manager->setGroupPermissions($id, $group, $permissions);

return new DataResponse(['success' => true]);
$folder = $this->getFolder($id);
return new DataResponse(['success' => true, 'folder' => $folder->getData()]);
}

/**
Expand All @@ -340,7 +344,7 @@ public function setPermissions(int $id, string $group, int $permissions): DataRe
* @param string $mappingType Type of the ACL mapping
* @param string $mappingId ID of the ACL mapping
* @param bool $manageAcl Whether to enable or disable the ACL mapping
* @return DataResponse<Http::STATUS_OK, array{success: true}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, list<empty>, array{}>
* @return DataResponse<Http::STATUS_OK, array{success: true, folder: GroupFoldersFolder}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, list<empty>, array{}>
*
* 200: ACL mapping updated successfully
* 404: Groupfolder not found
Expand All @@ -357,15 +361,16 @@ public function setManageACL(int $id, string $mappingType, string $mappingId, bo

$this->manager->setManageACL($id, $mappingType, $mappingId, $manageAcl);

return new DataResponse(['success' => true]);
$folder = $this->getFolder($id);
return new DataResponse(['success' => true, 'folder' => $folder->getData()]);
}

/**
* Set a new quota for a Groupfolder
*
* @param int $id ID of the Groupfolder
* @param int $quota New quota in bytes
* @return DataResponse<Http::STATUS_OK, array{success: true}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, list<empty>, array{}>
* @return DataResponse<Http::STATUS_OK, array{success: true, folder: GroupFoldersFolder}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, list<empty>, array{}>
*
* 200: New quota set successfully
* 404: Groupfolder not found
Expand All @@ -382,15 +387,16 @@ public function setQuota(int $id, int $quota): DataResponse {

$this->manager->setFolderQuota($id, $quota);

return new DataResponse(['success' => true]);
$folder = $this->getFolder($id);
return new DataResponse(['success' => true, 'folder' => $folder->getData()]);
}

/**
* Toggle the ACL for a Groupfolder
*
* @param int $id ID of the Groupfolder
* @param bool $acl Whether ACL should be enabled or not
* @return DataResponse<Http::STATUS_OK, array{success: true}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, list<empty>, array{}>
* @return DataResponse<Http::STATUS_OK, array{success: true, folder: GroupFoldersFolder}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, list<empty>, array{}>
*
* 200: ACL toggled successfully
* 404: Groupfolder not found
Expand All @@ -407,15 +413,16 @@ public function setACL(int $id, bool $acl): DataResponse {

$this->manager->setFolderACL($id, $acl);

return new DataResponse(['success' => true]);
$folder = $this->getFolder($id);
return new DataResponse(['success' => true, 'folder' => $folder->getData()]);
}

/**
* Rename a Groupfolder
*
* @param int $id ID of the Groupfolder
* @param string $mountpoint New Mountpoint of the Groupfolder
* @return DataResponse<Http::STATUS_OK, array{success: true}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, list<empty>, array{}>
* @return DataResponse<Http::STATUS_OK, array{success: true, folder: GroupFoldersFolder}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, list<empty>, array{}>
*
* 200: Groupfolder renamed successfully
* 404: Groupfolder not found
Expand All @@ -432,7 +439,8 @@ public function renameFolder(int $id, string $mountpoint): DataResponse {

$this->manager->renameFolder($id, trim($mountpoint));

return new DataResponse(['success' => true]);
$folder = $this->getFolder($id);
return new DataResponse(['success' => true, 'folder' => $folder->getData()]);
}

/**
Expand Down
48 changes: 40 additions & 8 deletions openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -942,14 +942,18 @@
"data": {
"type": "object",
"required": [
"success"
"success",
"folder"
],
"properties": {
"success": {
"type": "boolean",
"enum": [
true
]
},
"folder": {
"$ref": "#/components/schemas/Folder"
}
}
}
Expand Down Expand Up @@ -1044,14 +1048,18 @@
"data": {
"type": "object",
"required": [
"success"
"success",
"folder"
],
"properties": {
"success": {
"type": "boolean",
"enum": [
true
]
},
"folder": {
"$ref": "#/components/schemas/Folder"
}
}
}
Expand Down Expand Up @@ -1165,14 +1173,18 @@
"data": {
"type": "object",
"required": [
"success"
"success",
"folder"
],
"properties": {
"success": {
"type": "boolean",
"enum": [
true
]
},
"folder": {
"$ref": "#/components/schemas/Folder"
}
}
}
Expand Down Expand Up @@ -1304,14 +1316,18 @@
"data": {
"type": "object",
"required": [
"success"
"success",
"folder"
],
"properties": {
"success": {
"type": "boolean",
"enum": [
true
]
},
"folder": {
"$ref": "#/components/schemas/Folder"
}
}
}
Expand Down Expand Up @@ -1444,14 +1460,18 @@
"data": {
"type": "object",
"required": [
"success"
"success",
"folder"
],
"properties": {
"success": {
"type": "boolean",
"enum": [
true
]
},
"folder": {
"$ref": "#/components/schemas/Folder"
}
}
}
Expand Down Expand Up @@ -1575,14 +1595,18 @@
"data": {
"type": "object",
"required": [
"success"
"success",
"folder"
],
"properties": {
"success": {
"type": "boolean",
"enum": [
true
]
},
"folder": {
"$ref": "#/components/schemas/Folder"
}
}
}
Expand Down Expand Up @@ -1705,14 +1729,18 @@
"data": {
"type": "object",
"required": [
"success"
"success",
"folder"
],
"properties": {
"success": {
"type": "boolean",
"enum": [
true
]
},
"folder": {
"$ref": "#/components/schemas/Folder"
}
}
}
Expand Down Expand Up @@ -1835,14 +1863,18 @@
"data": {
"type": "object",
"required": [
"success"
"success",
"folder"
],
"properties": {
"success": {
"type": "boolean",
"enum": [
true
]
},
"folder": {
"$ref": "#/components/schemas/Folder"
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/types/openapi/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ export interface operations {
data: {
/** @enum {boolean} */
success: true;
folder: components["schemas"]["Folder"];
};
};
};
Expand Down Expand Up @@ -669,6 +670,7 @@ export interface operations {
data: {
/** @enum {boolean} */
success: true;
folder: components["schemas"]["Folder"];
};
};
};
Expand Down Expand Up @@ -729,6 +731,7 @@ export interface operations {
data: {
/** @enum {boolean} */
success: true;
folder: components["schemas"]["Folder"];
};
};
};
Expand Down Expand Up @@ -779,6 +782,7 @@ export interface operations {
data: {
/** @enum {boolean} */
success: true;
folder: components["schemas"]["Folder"];
};
};
};
Expand Down Expand Up @@ -838,6 +842,7 @@ export interface operations {
data: {
/** @enum {boolean} */
success: true;
folder: components["schemas"]["Folder"];
};
};
};
Expand Down Expand Up @@ -896,6 +901,7 @@ export interface operations {
data: {
/** @enum {boolean} */
success: true;
folder: components["schemas"]["Folder"];
};
};
};
Expand Down Expand Up @@ -951,6 +957,7 @@ export interface operations {
data: {
/** @enum {boolean} */
success: true;
folder: components["schemas"]["Folder"];
};
};
};
Expand Down Expand Up @@ -1006,6 +1013,7 @@ export interface operations {
data: {
/** @enum {boolean} */
success: true;
folder: components["schemas"]["Folder"];
};
};
};
Expand Down

0 comments on commit 66ae8bc

Please sign in to comment.