From 967b3848e0e2eeb7ca5447599769fd9fbf825069 Mon Sep 17 00:00:00 2001 From: skjnldsv Date: Tue, 9 Jul 2024 15:38:33 +0200 Subject: [PATCH] fix(files_sharing): phpunit & openapi fixes Signed-off-by: skjnldsv --- .../lib/Controller/ShareAPIController.php | 10 +- apps/files_sharing/openapi.json | 183 ++++++ .../src/components/NewFileRequestDialog.vue | 18 +- .../NewFileRequestDialogDatePassword.vue | 5 +- .../NewFileRequestDialogFinish.vue | 2 +- .../NewFileRequestDialogIntro.vue | 2 +- .../src/components/SharingEntryLink.vue | 2 +- .../src/components/SharingInput.vue | 1 - apps/files_sharing/src/models/Share.js | 1 - .../src/services/ConfigService.ts | 167 +++--- apps/files_sharing/tests/ApiTest.php | 6 + .../Controller/ShareAPIControllerTest.php | 58 +- .../files_sharing/tests/MountProviderTest.php | 20 +- apps/sharebymail/lib/ShareByMailProvider.php | 47 +- .../tests/ShareByMailProviderTest.php | 564 ++++++++++++------ lib/private/Share20/DefaultShareProvider.php | 14 +- lib/public/Share/IManager.php | 2 +- .../lib/Share20/DefaultShareProviderTest.php | 28 +- 18 files changed, 804 insertions(+), 326 deletions(-) diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index 0936d60b9cc..273dd30f7ef 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -2065,8 +2065,14 @@ class ShareAPIController extends OCSController { /** * Send a mail notification again for a share. * The mail_send option must be enabled for the given share. - * @param string $id + * @param string $id the share ID * @param string $password optional, the password to check against. Necessary for password protected shares. + * @throws OCSNotFoundException Share not found + * @throws OCSForbiddenException You are not allowed to send mail notifications + * @throws OCSBadRequestException Invalid request or wrong password + * @throws OCSException Error while sending mail notification + * @return DataResponse, array{}> + * 200: The email notification was sent successfully */ #[NoAdminRequired] #[UserRateLimit(limit: 5, period: 120)] @@ -2110,7 +2116,7 @@ class ShareAPIController extends OCSController { } $provider->sendMailNotification($share); - return new DataResponse(['message' => 'ok']); + return new DataResponse(); } catch(OCSBadRequestException $e) { throw $e; } catch (Exception $e) { diff --git a/apps/files_sharing/openapi.json b/apps/files_sharing/openapi.json index 65beb9121b8..8669fdcc8e1 100644 --- a/apps/files_sharing/openapi.json +++ b/apps/files_sharing/openapi.json @@ -1755,6 +1755,15 @@ "type": "string", "nullable": true, "description": "Additional attributes for the share" + }, + "sendMail": { + "type": "string", + "nullable": true, + "enum": [ + "false", + "true" + ], + "description": "Send a mail to the recipient" } } } @@ -2256,6 +2265,11 @@ "type": "string", "nullable": true, "description": "New additional attributes" + }, + "sendMail": { + "type": "string", + "nullable": true, + "description": "if the share should be send by mail.\n Considering the share already exists, no mail will be send after the share is updated.\n \t\t\t\t You will have to use the sendMail action to send the mail." } } } @@ -2523,6 +2537,175 @@ } } }, + "/ocs/v2.php/apps/files_sharing/api/v1/shares/{id}/send-email": { + "post": { + "operationId": "shareapi-send-share-email", + "summary": "Send a mail notification again for a share. The mail_send option must be enabled for the given share.", + "tags": [ + "shareapi" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "requestBody": { + "required": false, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "password": { + "type": "string", + "default": "", + "description": "optional, the password to check against. Necessary for password protected shares." + } + } + } + } + } + }, + "parameters": [ + { + "name": "id", + "in": "path", + "description": "the share ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "OCS-APIRequest", + "in": "header", + "description": "Required to be true for the API request to pass", + "required": true, + "schema": { + "type": "boolean", + "default": true + } + } + ], + "responses": { + "404": { + "description": "Share not found", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } + }, + "403": { + "description": "You are not allowed to send mail notifications", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } + }, + "400": { + "description": "Invalid request or wrong password", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } + }, + "200": { + "description": "The email notification was sent successfully", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } + } + } + } + }, "/ocs/v2.php/apps/files_sharing/api/v1/shares/pending/{id}": { "post": { "operationId": "shareapi-accept-share", diff --git a/apps/files_sharing/src/components/NewFileRequestDialog.vue b/apps/files_sharing/src/components/NewFileRequestDialog.vue index b0a969c25f1..6f5044d21e5 100644 --- a/apps/files_sharing/src/components/NewFileRequestDialog.vue +++ b/apps/files_sharing/src/components/NewFileRequestDialog.vue @@ -41,7 +41,7 @@ @@ -103,8 +103,9 @@