diff --git a/docs/content/en/docs/config/http/services/appprovider/_index.md b/docs/content/en/docs/config/http/services/appprovider/_index.md index 05a859dc85e..bda4901bfc2 100644 --- a/docs/content/en/docs/config/http/services/appprovider/_index.md +++ b/docs/content/en/docs/config/http/services/appprovider/_index.md @@ -9,7 +9,7 @@ description: > # _struct: Config_ {{% dir name="insecure" type="bool" default=false %}} -Whether to skip certificate checks when sending requests. [[Ref]](https://github.com/cs3org/reva/tree/master/internal/http/services/appprovider/appprovider.go#L55) +Whether to skip certificate checks when sending requests. [[Ref]](https://github.com/cs3org/reva/tree/master/internal/http/services/appprovider/appprovider.go#L56) {{< highlight toml >}} [http.services.appprovider] insecure = false diff --git a/internal/http/services/appprovider/appprovider.go b/internal/http/services/appprovider/appprovider.go index e95a2e99a73..f1966fe1bba 100644 --- a/internal/http/services/appprovider/appprovider.go +++ b/internal/http/services/appprovider/appprovider.go @@ -24,10 +24,11 @@ import ( "net/http" "path" + apppb "github.com/cs3org/go-cs3apis/cs3/app/provider/v1beta1" appregistry "github.com/cs3org/go-cs3apis/cs3/app/registry/v1beta1" gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1" rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1" - provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" + storagepb "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" typespb "github.com/cs3org/go-cs3apis/cs3/types/v1beta1" "github.com/cs3org/reva/internal/http/services/datagateway" "github.com/cs3org/reva/pkg/appctx" @@ -158,8 +159,8 @@ func (s *svc) handleNew(w http.ResponseWriter, r *http.Request) { return } - statParentContainerReq := &provider.StatRequest{ - Ref: &provider.Reference{ + statParentContainerReq := &storagepb.StatRequest{ + Ref: &storagepb.Reference{ ResourceId: parentContainerRef, }, } @@ -174,16 +175,16 @@ func (s *svc) handleNew(w http.ResponseWriter, r *http.Request) { return } - if parentContainer.Info.Type != provider.ResourceType_RESOURCE_TYPE_CONTAINER { + if parentContainer.Info.Type != storagepb.ResourceType_RESOURCE_TYPE_CONTAINER { writeError(w, r, appErrorInvalidParameter, "the parent container id does not point to a container", nil) return } - fileRef := &provider.Reference{ + fileRef := &storagepb.Reference{ Path: path.Join(parentContainer.Info.Path, utils.MakeRelativePath(filename)), } - statFileReq := &provider.StatRequest{ + statFileReq := &storagepb.StatRequest{ Ref: fileRef, } statFileRes, err := client.Stat(ctx, statFileReq) @@ -202,7 +203,7 @@ func (s *svc) handleNew(w http.ResponseWriter, r *http.Request) { } // Create empty file via storageprovider - createReq := &provider.InitiateFileUploadRequest{ + createReq := &storagepb.InitiateFileUploadRequest{ Ref: fileRef, Opaque: &typespb.Opaque{ Map: map[string]*typespb.OpaqueEntry{ @@ -269,7 +270,7 @@ func (s *svc) handleNew(w http.ResponseWriter, r *http.Request) { return } - if statRes.Info.Type != provider.ResourceType_RESOURCE_TYPE_FILE { + if statRes.Info.Type != storagepb.ResourceType_RESOURCE_TYPE_FILE { writeError(w, r, appErrorInvalidParameter, "the given file id does not point to a file", nil) return } @@ -339,7 +340,7 @@ func (s *svc) handleOpen(w http.ResponseWriter, r *http.Request) { fileID := r.Form.Get("file_id") - var fileRef provider.Reference + var fileRef storagepb.Reference if fileID == "" { path := r.Form.Get("path") if path == "" { @@ -356,7 +357,7 @@ func (s *svc) handleOpen(w http.ResponseWriter, r *http.Request) { fileRef.ResourceId = resourceID } - statRes, err := client.Stat(ctx, &provider.StatRequest{Ref: &fileRef}) + statRes, err := client.Stat(ctx, &storagepb.StatRequest{Ref: &fileRef}) if err != nil { writeError(w, r, appErrorServerError, "Internal error accessing the file, please try again later", err) return @@ -370,7 +371,7 @@ func (s *svc) handleOpen(w http.ResponseWriter, r *http.Request) { return } - if statRes.Info.Type != provider.ResourceType_RESOURCE_TYPE_FILE { + if statRes.Info.Type != storagepb.ResourceType_RESOURCE_TYPE_FILE { writeError(w, r, appErrorInvalidParameter, "the given file id does not point to a file", nil) return } @@ -417,7 +418,16 @@ func (s *svc) handleOpen(w http.ResponseWriter, r *http.Request) { return } - js, err := json.Marshal(openRes.AppUrl) + // recreate the structure to marshal the AppUrl.Target as a string + js, err := json.Marshal( + map[string]interface{}{ + "app_url": openRes.AppUrl.AppUrl, + "method": openRes.AppUrl.Method, + "form_parameters": openRes.AppUrl.FormParameters, + "headers": openRes.AppUrl.Headers, + "target": appTargetToString(openRes.AppUrl.Target), + }, + ) if err != nil { writeError(w, r, appErrorServerError, "Internal error with JSON payload", errors.Wrap(err, "error marshalling JSON response")) @@ -442,7 +452,7 @@ func (s *svc) handleNotify(w http.ResponseWriter, r *http.Request) { } fileID := r.Form.Get("file_id") - var fileRef provider.Reference + var fileRef storagepb.Reference if fileID == "" { path := r.Form.Get("path") if path == "" { @@ -488,7 +498,7 @@ func filterAppsByUserAgent(mimeTypes []*appregistry.MimeTypeInfo, userAgent stri return res } -func resolveViewMode(res *provider.ResourceInfo, vm string) gateway.OpenInAppRequest_ViewMode { +func resolveViewMode(res *storagepb.ResourceInfo, vm string) gateway.OpenInAppRequest_ViewMode { var viewMode gateway.OpenInAppRequest_ViewMode if vm != "" { viewMode = utils.GetViewMode(vm) @@ -512,3 +522,14 @@ func resolveViewMode(res *provider.ResourceInfo, vm string) gateway.OpenInAppReq } return viewMode } + +func appTargetToString(t apppb.Target) string { + switch t { + case apppb.Target_TARGET_IFRAME: + return "iframe" + case apppb.Target_TARGET_BLANK: + return "blank" + default: + return "iframe" + } +}