From 330bf1794a64a636608a0bc89affd02f70d9e3a5 Mon Sep 17 00:00:00 2001 From: David Christofas Date: Wed, 8 Sep 2021 11:07:29 -0400 Subject: [PATCH] fix response after deleting a share (#2054) Added the deleted share to the response after deleting it. --- changelog/unreleased/delete-share-response.md | 5 +++ .../ocs/handlers/apps/sharing/shares/user.go | 35 +++++++++++++++---- .../expected-failures-on-OCIS-storage.md | 5 --- .../expected-failures-on-S3NG-storage.md | 5 --- 4 files changed, 33 insertions(+), 17 deletions(-) create mode 100644 changelog/unreleased/delete-share-response.md diff --git a/changelog/unreleased/delete-share-response.md b/changelog/unreleased/delete-share-response.md new file mode 100644 index 0000000000..8777e2f4f7 --- /dev/null +++ b/changelog/unreleased/delete-share-response.md @@ -0,0 +1,5 @@ +Bugfix: Fix the response after deleting a share + +Added the deleted share to the response after deleting it. + +https://github.com/cs3org/reva/pull/2054 diff --git a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/user.go b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/user.go index 7ce8822d97..22cc7ef477 100644 --- a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/user.go +++ b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/user.go @@ -94,15 +94,36 @@ func (h *Handler) removeUserShare(w http.ResponseWriter, r *http.Request, shareI return } - uReq := &collaboration.RemoveShareRequest{ - Ref: &collaboration.ShareReference{ - Spec: &collaboration.ShareReference_Id{ - Id: &collaboration.ShareId{ - OpaqueId: shareID, - }, + shareRef := &collaboration.ShareReference{ + Spec: &collaboration.ShareReference_Id{ + Id: &collaboration.ShareId{ + OpaqueId: shareID, }, }, } + // Get the share, so that we can include it in the response. + getShareResp, err := uClient.GetShare(ctx, &collaboration.GetShareRequest{Ref: shareRef}) + if err != nil { + response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "error sending a grpc delete share request", err) + return + } else if getShareResp.Status.Code != rpc.Code_CODE_OK { + if getShareResp.Status.Code == rpc.Code_CODE_NOT_FOUND { + response.WriteOCSError(w, r, response.MetaNotFound.StatusCode, "not found", nil) + return + } + response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "deleting share failed", err) + return + } + + data, err := conversions.CS3Share2ShareData(ctx, getShareResp.Share) + if err != nil { + response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "deleting share failed", err) + return + } + // A deleted share should not have an ID. + data.ID = "" + + uReq := &collaboration.RemoveShareRequest{Ref: shareRef} uRes, err := uClient.RemoveShare(ctx, uReq) if err != nil { response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "error sending a grpc delete share request", err) @@ -117,7 +138,7 @@ func (h *Handler) removeUserShare(w http.ResponseWriter, r *http.Request, shareI response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "grpc delete share request failed", err) return } - response.WriteOCSSuccess(w, r, nil) + response.WriteOCSSuccess(w, r, data) } func (h *Handler) listUserShares(r *http.Request, filters []*collaboration.Filter) ([]*conversions.ShareData, *rpc.Status, error) { diff --git a/tests/acceptance/expected-failures-on-OCIS-storage.md b/tests/acceptance/expected-failures-on-OCIS-storage.md index 844697ad18..e24d4cebff 100644 --- a/tests/acceptance/expected-failures-on-OCIS-storage.md +++ b/tests/acceptance/expected-failures-on-OCIS-storage.md @@ -349,11 +349,6 @@ The first two tests work against ocis. There must be something wrong in the CI s #### [Cannot move a file to a shared folder](https://github.com/owncloud/ocis/issues/2146) - [apiShareManagementBasicToShares/createShareToSharesFolder.feature:515](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareManagementBasicToShares/createShareToSharesFolder.feature#L515) -#### [deleting share response does not contain `data` field](https://github.com/owncloud/ocis/issues/721) - -- [apiShareManagementBasicToShares/deleteShareFromShares.feature:43](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareManagementBasicToShares/deleteShareFromShares.feature#L43) -- [apiShareManagementBasicToShares/deleteShareFromShares.feature:44](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareManagementBasicToShares/deleteShareFromShares.feature#L44) - #### [sharing via API and changing the cases in the username does not work correctly](https://github.com/owncloud/core/issues/35484) - [apiShareManagementBasicToShares/createShareToSharesFolder.feature:373](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareManagementBasicToShares/createShareToSharesFolder.feature#L373) diff --git a/tests/acceptance/expected-failures-on-S3NG-storage.md b/tests/acceptance/expected-failures-on-S3NG-storage.md index cbd5ac6dde..c814e0c2c7 100644 --- a/tests/acceptance/expected-failures-on-S3NG-storage.md +++ b/tests/acceptance/expected-failures-on-S3NG-storage.md @@ -358,11 +358,6 @@ File and sync features in a shared scenario #### [Cannot move a file to a shared folder](https://github.com/owncloud/ocis/issues/2146) - [apiShareManagementBasicToShares/createShareToSharesFolder.feature:515](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareManagementBasicToShares/createShareToSharesFolder.feature#L515) -#### [deleting share response does not contain `data` field](https://github.com/owncloud/ocis/issues/721) - -- [apiShareManagementBasicToShares/deleteShareFromShares.feature:43](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareManagementBasicToShares/deleteShareFromShares.feature#L43) -- [apiShareManagementBasicToShares/deleteShareFromShares.feature:44](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareManagementBasicToShares/deleteShareFromShares.feature#L44) - #### [path property in pending shares gives only filename](https://github.com/owncloud/ocis/issues/2156) - [apiShareManagementBasicToShares/createShareToSharesFolder.feature:373](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareManagementBasicToShares/createShareToSharesFolder.feature#L373) - [apiShareManagementBasicToShares/createShareToSharesFolder.feature:543](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareManagementBasicToShares/createShareToSharesFolder.feature#L543)