From 37c0d328ec54509e4034d565a4acb3b5701d70a7 Mon Sep 17 00:00:00 2001 From: Gianmaria Del Monte Date: Wed, 7 Jun 2023 13:57:26 +0200 Subject: [PATCH] return share id when accepting/reject ocm share --- .../handlers/apps/sharing/shares/pending.go | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/pending.go b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/pending.go index b06d7d207fc..6eb049c20e7 100644 --- a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/pending.go +++ b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/pending.go @@ -128,6 +128,28 @@ func (h *Handler) updateReceivedFederatedShare(w http.ResponseWriter, r *http.Re return } + share, err := client.GetReceivedOCMShare(ctx, &ocmv1beta1.GetReceivedOCMShareRequest{ + Ref: &ocmv1beta1.ShareReference{ + Spec: &ocmv1beta1.ShareReference_Id{ + Id: &ocmv1beta1.ShareId{ + OpaqueId: shareID, + }, + }, + }, + }) + if err != nil { + response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "grpc update received share request failed", err) + return + } + if share.Status.Code != rpc.Code_CODE_OK { + if share.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, "grpc update received share request failed", errors.Errorf("code: %d, message: %s", share.Status.Code, share.Status.Message)) + return + } + req := &ocmv1beta1.UpdateReceivedOCMShareRequest{ Share: &ocmv1beta1.ReceivedShare{ Id: &ocmv1beta1.ShareId{ @@ -157,5 +179,12 @@ func (h *Handler) updateReceivedFederatedShare(w http.ResponseWriter, r *http.Re return } - response.WriteOCSSuccess(w, r, []*conversions.ShareData{}) + share.Share.State = req.Share.State + data, err := conversions.ReceivedOCMShare2ShareData(share.Share, h.ocmLocalMount(share.Share)) + if err != nil { + response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "grpc update received share request failed", err) + return + } + h.mapUserIdsReceivedFederatedShare(ctx, client, data) + response.WriteOCSSuccess(w, r, []*conversions.ShareData{data}) }