aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib/Controller/ShareInfoController.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_sharing/lib/Controller/ShareInfoController.php')
-rw-r--r--apps/files_sharing/lib/Controller/ShareInfoController.php32
1 files changed, 28 insertions, 4 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareInfoController.php b/apps/files_sharing/lib/Controller/ShareInfoController.php
index b6242f9ee9a..14f69b9703f 100644
--- a/apps/files_sharing/lib/Controller/ShareInfoController.php
+++ b/apps/files_sharing/lib/Controller/ShareInfoController.php
@@ -4,6 +4,7 @@
*
* @author Morris Jobke <hey@morrisjobke.de>
* @author Roeland Jago Douma <roeland@famdouma.nl>
+ * @author Kate Döen <kate.doeen@nextcloud.com>
*
* @license GNU AGPL version 3 or any later version
*
@@ -24,6 +25,7 @@
namespace OCA\Files_Sharing\Controller;
use OCA\Files_External\NotFoundException;
+use OCA\Files_Sharing\ResponseDefinitions;
use OCP\AppFramework\ApiController;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse;
@@ -35,6 +37,9 @@ use OCP\IRequest;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager;
+/**
+ * @psalm-import-type FilesSharingShareInfo from ResponseDefinitions
+ */
class ShareInfoController extends ApiController {
/** @var IManager */
@@ -60,10 +65,17 @@ class ShareInfoController extends ApiController {
* @NoCSRFRequired
* @BruteForceProtection(action=shareinfo)
*
- * @param string $t
- * @param ?string $password
- * @param ?string $dir
- * @return JSONResponse
+ * Get the info about a share
+ *
+ * @param string $t Token of the share
+ * @param string|null $password Password of the share
+ * @param string|null $dir Subdirectory to get info about
+ * @param int $depth Maximum depth to get info about
+ * @return JSONResponse<Http::STATUS_OK, FilesSharingShareInfo, array{}>|JSONResponse<Http::STATUS_FORBIDDEN|Http::STATUS_NOT_FOUND, array<empty>, array{}>
+ *
+ * 200: Share info returned
+ * 403: Getting share info is not allowed
+ * 404: Share not found
*/
public function info(string $t, ?string $password = null, ?string $dir = null, int $depth = -1): JSONResponse {
try {
@@ -99,6 +111,9 @@ class ShareInfoController extends ApiController {
return new JSONResponse($this->parseNode($node, $permissionMask, $depth));
}
+ /**
+ * @return FilesSharingShareInfo
+ */
private function parseNode(Node $node, int $permissionMask, int $depth): array {
if ($node instanceof File) {
return $this->parseFile($node, $permissionMask);
@@ -107,10 +122,16 @@ class ShareInfoController extends ApiController {
return $this->parseFolder($node, $permissionMask, $depth);
}
+ /**
+ * @return FilesSharingShareInfo
+ */
private function parseFile(File $file, int $permissionMask): array {
return $this->format($file, $permissionMask);
}
+ /**
+ * @return FilesSharingShareInfo
+ */
private function parseFolder(Folder $folder, int $permissionMask, int $depth): array {
$data = $this->format($folder, $permissionMask);
@@ -128,6 +149,9 @@ class ShareInfoController extends ApiController {
return $data;
}
+ /**
+ * @return FilesSharingShareInfo
+ */
private function format(Node $node, int $permissionMask): array {
$entry = [];