@@ -32,6 +32,7 @@ import (
3232 "github.com/cs3org/reva/v3/pkg/trace"
3333 "google.golang.org/grpc/codes"
3434 rpcstatus "google.golang.org/grpc/status"
35+ "google.golang.org/protobuf/types/known/fieldmaskpb"
3536
3637 ocmconversions "github.com/cs3org/reva/v3/pkg/ocm/conversions"
3738 "github.com/cs3org/reva/v3/pkg/rgrpc/todo/pool"
@@ -54,6 +55,47 @@ func (h *embeddedHandler) init(c *config) error {
5455 return nil
5556}
5657
58+ func (h * embeddedHandler ) ProcessEmbeddedShare (w http.ResponseWriter , r * http.Request ) {
59+ ctx := r .Context ()
60+ log := appctx .GetLogger (ctx )
61+ queryParams := r .URL .Query ()
62+
63+ dest_path := queryParams .Get ("destination" )
64+ share_id := queryParams .Get ("share_id" )
65+ process := queryParams .Get ("process" )
66+
67+ // For now we just log the destination path, but we don't use it yet.
68+ log .Debug ().Str ("share_id" , share_id ).Str ("dest_path" , dest_path ).Msg ("processing embedded share" )
69+
70+ req := ocm.UpdateReceivedOCMShareRequest {
71+ Share : & ocm.ReceivedShare {
72+ Id : & ocm.ShareId {
73+ OpaqueId : share_id ,
74+ },
75+ },
76+ UpdateMask : & fieldmaskpb.FieldMask {Paths : []string {"state" }},
77+ }
78+
79+ // Accept the embedded share or set it back to pending
80+ // depending on the "process" query parameter
81+ switch process {
82+ case "true" :
83+ req .Share .State = ocm .ShareState_SHARE_STATE_ACCEPTED
84+ case "false" :
85+ req .Share .State = ocm .ShareState_SHARE_STATE_PENDING
86+ }
87+
88+ _ , err := h .gatewayClient .UpdateReceivedOCMShare (ctx , & req )
89+
90+ if err != nil {
91+ log .Error ().Err (err ).Msg ("error accepting embedded share" )
92+ reqres .WriteError (w , r , reqres .APIErrorServerError , "error accepting embedded share" , err )
93+ return
94+ }
95+
96+ w .WriteHeader (http .StatusOK )
97+ }
98+
5799// ListEmbeddedShares lists all embedded ocm shares for the current user.
58100func (h * embeddedHandler ) ListEmbeddedShares (w http.ResponseWriter , r * http.Request ) {
59101 ctx := r .Context ()
0 commit comments