diff --git a/changelog/unreleased/improve-open-in-app.md b/changelog/unreleased/improve-open-in-app.md new file mode 100644 index 00000000000..9cff09975ce --- /dev/null +++ b/changelog/unreleased/improve-open-in-app.md @@ -0,0 +1,7 @@ +Enhancement: Open in app workflow using the new API + +This provides a new `open-in-app` command for the CLI and the implementation +on the appprovider gateway service for the new API, including the option +to specify the appplication to use, thus overriding the preconfigured one. + +https://github.com/cs3org/reva/pull/1723 diff --git a/cmd/reva/completer.go b/cmd/reva/completer.go index 88fa169492b..1f70ab97c2e 100644 --- a/cmd/reva/completer.go +++ b/cmd/reva/completer.go @@ -106,7 +106,7 @@ func (c *Completer) argumentCompleter(args ...string) []prompt.Suggest { return prompt.FilterHasPrefix(c.lsArgumentCompleter(false), args[2], true) } - case "rm", "stat", "share-create", "ocm-share-create", "public-share-create", "open-file-in-app-provider", "download": + case "rm", "stat", "share-create", "ocm-share-create", "public-share-create", "open-in-app", "open-file-in-app-provider", "download": if len(args) == 2 { return prompt.FilterHasPrefix(c.lsArgumentCompleter(false), args[1], true) } diff --git a/cmd/reva/open-file-in-app-provider.go b/cmd/reva/open-file-in-app-provider.go index c4514a0fd45..92a07666bdc 100644 --- a/cmd/reva/open-file-in-app-provider.go +++ b/cmd/reva/open-file-in-app-provider.go @@ -52,7 +52,7 @@ func openFileInAppProviderCommand() *command { } path := cmd.Args()[0] - vm := getViewMode(*viewMode) + vm := getViewMode_old(*viewMode) client, err := getClient() if err != nil { @@ -91,7 +91,7 @@ func openFileInAppProviderCommand() *command { return cmd } -func getViewMode(viewMode string) gateway.OpenFileInAppProviderRequest_ViewMode { +func getViewMode_old(viewMode string) gateway.OpenFileInAppProviderRequest_ViewMode { switch viewMode { case "view": return gateway.OpenFileInAppProviderRequest_VIEW_MODE_VIEW_ONLY diff --git a/cmd/reva/open-in-app.go b/cmd/reva/open-in-app.go new file mode 100644 index 00000000000..9e1b7279628 --- /dev/null +++ b/cmd/reva/open-in-app.go @@ -0,0 +1,107 @@ +// Copyright 2018-2021 CERN +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// In applying this license, CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +package main + +import ( + "fmt" + "io" + + 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" + typespb "github.com/cs3org/go-cs3apis/cs3/types/v1beta1" + "github.com/pkg/errors" +) + +func openInAppCommand() *command { + cmd := newCommand("open-in-app") + cmd.Description = func() string { return "open a reference in an external app provider" } + cmd.Usage = func() string { + return "Usage: open-in-app [-flags] [-viewmode view|read|write] [-app appname] " + } + viewMode := cmd.String("viewmode", "view", "the view permissions, defaults to view") + app := cmd.String("app", "", "the application if the default is to be overridden for the file's mimetype") + insecureFlag := cmd.Bool("insecure", false, "disables grpc transport security") + skipVerifyFlag := cmd.Bool("skip-verify", false, "whether to skip verifying remote reva's certificate chain and host name") + + cmd.ResetFlags = func() { + *viewMode = "view" + *app = "" + *insecureFlag = false + *skipVerifyFlag = false + } + + cmd.Action = func(w ...io.Writer) error { + ctx := getAuthContext() + if cmd.NArg() < 1 { + return errors.New("Invalid arguments: " + cmd.Usage()) + } + path := cmd.Args()[0] + + vm := getViewMode(*viewMode) + + client, err := getClient() + if err != nil { + return err + } + + ref := &provider.Reference{ + Spec: &provider.Reference_Path{Path: path}, + } + + opaqueObj := &typespb.Opaque{ + Map: map[string]*typespb.OpaqueEntry{}, + } + if *insecureFlag { + opaqueObj.Map["insecure"] = &typespb.OpaqueEntry{} + } + if *skipVerifyFlag { + opaqueObj.Map["skip-verify"] = &typespb.OpaqueEntry{} + } + + openRequest := &gateway.OpenInAppRequest{Ref: ref, ViewMode: vm, App: app, Opaque: opaqueObj} + + openRes, err := client.OpenInApp(ctx, openRequest) + if err != nil { + return err + } + + if openRes.Status.Code != rpc.Code_CODE_OK { + return formatError(openRes.Status) + } + + fmt.Println("App URL: " + openRes.AppUrl) + + return nil + } + return cmd +} + +func getViewMode(viewMode string) gateway.OpenInAppRequest_ViewMode { + switch viewMode { + case "view": + return gateway.OpenInAppRequest_VIEW_MODE_VIEW_ONLY + case "read": + return gateway.OpenInAppRequest_VIEW_MODE_READ_ONLY + case "write": + return gateway.OpenInAppRequest_VIEW_MODE_READ_WRITE + default: + return gateway.OpenInAppRequest_VIEW_MODE_INVALID + } +} diff --git a/docs/content/en/docs/config/grpc/services/appprovider/_index.md b/docs/content/en/docs/config/grpc/services/appprovider/_index.md index c243fe79e87..f548d91748a 100644 --- a/docs/content/en/docs/config/grpc/services/appprovider/_index.md +++ b/docs/content/en/docs/config/grpc/services/appprovider/_index.md @@ -9,7 +9,7 @@ description: > # _struct: config_ {{% dir name="iopsecret" type="string" default="" %}} -The iopsecret used to connect to the wopiserver. [[Ref]](https://github.com/cs3org/reva/tree/master/internal/grpc/services/appprovider/appprovider.go#L59) +The iopsecret used to connect to the wopiserver. [[Ref]](https://github.com/cs3org/reva/tree/master/internal/grpc/services/appprovider/appprovider.go#L60) {{< highlight toml >}} [grpc.services.appprovider] iopsecret = "" @@ -17,7 +17,7 @@ iopsecret = "" {{% /dir %}} {{% dir name="wopiurl" type="string" default="" %}} -The wopiserver's URL. [[Ref]](https://github.com/cs3org/reva/tree/master/internal/grpc/services/appprovider/appprovider.go#L60) +The wopiserver's URL. [[Ref]](https://github.com/cs3org/reva/tree/master/internal/grpc/services/appprovider/appprovider.go#L61) {{< highlight toml >}} [grpc.services.appprovider] wopiurl = "" @@ -25,7 +25,7 @@ wopiurl = "" {{% /dir %}} {{% dir name="wopibridgeurl" type="string" default="" %}} -The wopibridge's URL. [[Ref]](https://github.com/cs3org/reva/tree/master/internal/grpc/services/appprovider/appprovider.go#L61) +The wopibridge's URL. [[Ref]](https://github.com/cs3org/reva/tree/master/internal/grpc/services/appprovider/appprovider.go#L62) {{< highlight toml >}} [grpc.services.appprovider] wopibridgeurl = "" diff --git a/docs/content/en/docs/config/packages/auth/manager/oidc/_index.md b/docs/content/en/docs/config/packages/auth/manager/oidc/_index.md index 5e457997938..6abc8039f10 100644 --- a/docs/content/en/docs/config/packages/auth/manager/oidc/_index.md +++ b/docs/content/en/docs/config/packages/auth/manager/oidc/_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/pkg/auth/manager/oidc/oidc.go#L53) +Whether to skip certificate checks when sending requests. [[Ref]](https://github.com/cs3org/reva/tree/master/pkg/auth/manager/oidc/oidc.go#L55) {{< highlight toml >}} [auth.manager.oidc] insecure = false @@ -17,7 +17,7 @@ insecure = false {{% /dir %}} {{% dir name="issuer" type="string" default="" %}} -The issuer of the OIDC token. [[Ref]](https://github.com/cs3org/reva/tree/master/pkg/auth/manager/oidc/oidc.go#L54) +The issuer of the OIDC token. [[Ref]](https://github.com/cs3org/reva/tree/master/pkg/auth/manager/oidc/oidc.go#L56) {{< highlight toml >}} [auth.manager.oidc] issuer = "" @@ -25,7 +25,7 @@ issuer = "" {{% /dir %}} {{% dir name="id_claim" type="string" default="sub" %}} -The claim containing the ID of the user. [[Ref]](https://github.com/cs3org/reva/tree/master/pkg/auth/manager/oidc/oidc.go#L55) +The claim containing the ID of the user. [[Ref]](https://github.com/cs3org/reva/tree/master/pkg/auth/manager/oidc/oidc.go#L57) {{< highlight toml >}} [auth.manager.oidc] id_claim = "sub" @@ -33,7 +33,7 @@ id_claim = "sub" {{% /dir %}} {{% dir name="uid_claim" type="string" default="" %}} -The claim containing the UID of the user. [[Ref]](https://github.com/cs3org/reva/tree/master/pkg/auth/manager/oidc/oidc.go#L56) +The claim containing the UID of the user. [[Ref]](https://github.com/cs3org/reva/tree/master/pkg/auth/manager/oidc/oidc.go#L58) {{< highlight toml >}} [auth.manager.oidc] uid_claim = "" @@ -41,7 +41,7 @@ uid_claim = "" {{% /dir %}} {{% dir name="gid_claim" type="string" default="" %}} -The claim containing the GID of the user. [[Ref]](https://github.com/cs3org/reva/tree/master/pkg/auth/manager/oidc/oidc.go#L57) +The claim containing the GID of the user. [[Ref]](https://github.com/cs3org/reva/tree/master/pkg/auth/manager/oidc/oidc.go#L59) {{< highlight toml >}} [auth.manager.oidc] gid_claim = "" @@ -49,7 +49,7 @@ gid_claim = "" {{% /dir %}} {{% dir name="gatewaysvc" type="string" default="" %}} -The endpoint at which the GRPC gateway is exposed. [[Ref]](https://github.com/cs3org/reva/tree/master/pkg/auth/manager/oidc/oidc.go#L58) +The endpoint at which the GRPC gateway is exposed. [[Ref]](https://github.com/cs3org/reva/tree/master/pkg/auth/manager/oidc/oidc.go#L60) {{< highlight toml >}} [auth.manager.oidc] gatewaysvc = "" diff --git a/docs/content/en/docs/tutorials/wopi-tutorial.md b/docs/content/en/docs/tutorials/wopi-tutorial.md index f1347f9f145..053d0e68158 100644 --- a/docs/content/en/docs/tutorials/wopi-tutorial.md +++ b/docs/content/en/docs/tutorials/wopi-tutorial.md @@ -93,6 +93,6 @@ Run according to instructions in the readme ("Run the WOPI server locally", http ## 7. Local changes To try the connection you could for example go to a new reva terminal window and type `./cmd/reva/reva -insecure login basic` - use einstein and relativity as log in ccredentials -`./cmd/reva/reva -insecure open-file-in-app-provider /home/example.txt read` - this should print out the app provider url in your terminal. +`./cmd/reva/reva -insecure open-in-app /home/example.txt read` - this should print out the app provider url in your terminal. ## 8. Enjoy your new Reva and wopiserver set up! diff --git a/internal/grpc/services/appprovider/appprovider.go b/internal/grpc/services/appprovider/appprovider.go index b4b48674990..b7545f7927e 100644 --- a/internal/grpc/services/appprovider/appprovider.go +++ b/internal/grpc/services/appprovider/appprovider.go @@ -150,7 +150,7 @@ func (s *service) getWopiAppEndpoints(ctx context.Context) (map[string]interface return appsURLMap, nil } -func (s *service) OpenFileInAppProvider(ctx context.Context, req *providerpb.OpenFileInAppProviderRequest) (*providerpb.OpenFileInAppProviderResponse, error) { +func (s *service) OpenInApp(ctx context.Context, req *providerpb.OpenInAppRequest) (*providerpb.OpenInAppResponse, error) { log := appctx.GetLogger(ctx) @@ -189,7 +189,7 @@ func (s *service) OpenFileInAppProvider(ctx context.Context, req *providerpb.Ope openRes, err := s.client.Do(httpReq) if err != nil { - res := &providerpb.OpenFileInAppProviderResponse{ + res := &providerpb.OpenInAppResponse{ Status: status.NewInternal(ctx, err, "appprovider: error performing open request to WOPI"), } return res, nil @@ -197,7 +197,7 @@ func (s *service) OpenFileInAppProvider(ctx context.Context, req *providerpb.Ope defer openRes.Body.Close() if openRes.StatusCode != http.StatusOK { - res := &providerpb.OpenFileInAppProviderResponse{ + res := &providerpb.OpenInAppResponse{ Status: status.NewInvalid(ctx, fmt.Sprintf("appprovider: error performing open request to WOPI, status code: %d", openRes.StatusCode)), } return res, nil @@ -210,37 +210,45 @@ func (s *service) OpenFileInAppProvider(ctx context.Context, req *providerpb.Ope } openResBody := buf.String() - // TODO call this e.g. once a day or a week, and cache the content in a shared map protected by a multi-reader Lock - appsURLMap, err := s.getWopiAppEndpoints(ctx) - if err != nil { - res := &providerpb.OpenFileInAppProviderResponse{ - Status: status.NewInternal(ctx, err, "appprovider: getWopiAppEndpoints failed"), - } - return res, nil - } - viewOptions := appsURLMap[path.Ext(req.ResourceInfo.GetPath())] - viewOptionsMap, ok := viewOptions.(map[string]interface{}) - if !ok { - res := &providerpb.OpenFileInAppProviderResponse{ - Status: status.NewInvalid(ctx, "Incorrect parsing of the App URLs map from the WOPI server"), - } - return res, nil - } - var viewmode string - if req.ViewMode == providerpb.OpenFileInAppProviderRequest_VIEW_MODE_READ_WRITE { + if req.ViewMode == providerpb.OpenInAppRequest_VIEW_MODE_READ_WRITE { viewmode = "edit" } else { viewmode = "view" } - appProviderURL := fmt.Sprintf("%v", viewOptionsMap[viewmode]) - if strings.Contains(appProviderURL, "?") { - appProviderURL += "&" + var appProviderURL string + if req.App == "" { + // Default behavior: work out the application URL to be used for this file + // TODO call this e.g. once a day or a week, and cache the content in a shared map protected by a multi-reader Lock + appsURLMap, err := s.getWopiAppEndpoints(ctx) + if err != nil { + res := &providerpb.OpenInAppResponse{ + Status: status.NewInternal(ctx, err, "appprovider: getWopiAppEndpoints failed"), + } + return res, nil + } + viewOptions := appsURLMap[path.Ext(req.ResourceInfo.GetPath())] + viewOptionsMap, ok := viewOptions.(map[string]interface{}) + if !ok { + res := &providerpb.OpenInAppResponse{ + Status: status.NewInvalid(ctx, "Incorrect parsing of the App URLs map from the WOPI server"), + } + return res, nil + } + + appProviderURL = fmt.Sprintf("%v", viewOptionsMap[viewmode]) + if strings.Contains(appProviderURL, "?") { + appProviderURL += "&" + } else { + appProviderURL += "?" + } + appProviderURL = fmt.Sprintf("%sWOPISrc=%s", appProviderURL, openResBody) } else { - appProviderURL += "?" + // User specified the application to use, generate the URL out of that + // TODO map the given req.App to the URL via config. For now assume it's a URL! + appProviderURL = fmt.Sprintf("%sWOPISrc=%s", req.App, openResBody) } - appProviderURL = fmt.Sprintf("%sWOPISrc=%s", appProviderURL, openResBody) // In case of applications served by the WOPI bridge, resolve the URL and go to the app // Note that URL matching is performed via string matching, not via IP resolution: may need to fix this @@ -270,12 +278,12 @@ func (s *service) OpenFileInAppProvider(ctx context.Context, req *providerpb.Ope } log.Info().Msg(fmt.Sprintf("Returning app provider URL %s", appProviderURL)) - return &providerpb.OpenFileInAppProviderResponse{ - Status: status.NewOK(ctx), - AppProviderUrl: appProviderURL, + return &providerpb.OpenInAppResponse{ + Status: status.NewOK(ctx), + AppUrl: appProviderURL, }, nil } -func (s *service) OpenInApp(ctx context.Context, req *providerpb.OpenInAppRequest) (*providerpb.OpenInAppResponse, error) { - return nil, errtypes.NotSupported("Unimplemented") +func (s *service) OpenFileInAppProvider(ctx context.Context, req *providerpb.OpenFileInAppProviderRequest) (*providerpb.OpenFileInAppProviderResponse, error) { + return nil, errtypes.NotSupported("Deprecated") } diff --git a/internal/grpc/services/gateway/appprovider.go b/internal/grpc/services/gateway/appprovider.go index b66c42dfe26..405c4a3dd9f 100644 --- a/internal/grpc/services/gateway/appprovider.go +++ b/internal/grpc/services/gateway/appprovider.go @@ -42,21 +42,21 @@ import ( "google.golang.org/grpc/metadata" ) -func (s *svc) OpenFileInAppProvider(ctx context.Context, req *gateway.OpenFileInAppProviderRequest) (*providerpb.OpenFileInAppProviderResponse, error) { +func (s *svc) OpenInApp(ctx context.Context, req *gateway.OpenInAppRequest) (*providerpb.OpenInAppResponse, error) { p, st := s.getPath(ctx, req.Ref) if st.Code != rpc.Code_CODE_OK { if st.Code == rpc.Code_CODE_NOT_FOUND { - return &providerpb.OpenFileInAppProviderResponse{ - Status: status.NewNotFound(ctx, "gateway: file not found:"+req.Ref.String()), + return &providerpb.OpenInAppResponse{ + Status: status.NewNotFound(ctx, "gateway: resource not found:"+req.Ref.String()), }, nil } - return &providerpb.OpenFileInAppProviderResponse{ + return &providerpb.OpenInAppResponse{ Status: st, }, nil } if s.isSharedFolder(ctx, p) { - return &providerpb.OpenFileInAppProviderResponse{ + return &providerpb.OpenInAppResponse{ Status: status.NewInvalid(ctx, "gateway: can't open shares folder"), }, nil } @@ -74,13 +74,13 @@ func (s *svc) OpenFileInAppProvider(ctx context.Context, req *gateway.OpenFileIn }, }) if err != nil { - return &providerpb.OpenFileInAppProviderResponse{ + return &providerpb.OpenInAppResponse{ Status: status.NewInternal(ctx, err, "gateway: error calling Stat on the resource path for the app provider: "+req.Ref.GetPath()), }, nil } if statRes.Status.Code != rpc.Code_CODE_OK { err := status.NewErrorFromCode(statRes.Status.GetCode(), "gateway") - return &providerpb.OpenFileInAppProviderResponse{ + return &providerpb.OpenInAppResponse{ Status: status.NewInternal(ctx, err, "Stat failed on the resource path for the app provider: "+req.Ref.GetPath()), }, nil } @@ -91,36 +91,41 @@ func (s *svc) OpenFileInAppProvider(ctx context.Context, req *gateway.OpenFileIn if fileInfo.Type == storageprovider.ResourceType_RESOURCE_TYPE_REFERENCE { uri, err := url.Parse(fileInfo.Target) if err != nil { - return &providerpb.OpenFileInAppProviderResponse{ + return &providerpb.OpenInAppResponse{ Status: status.NewInternal(ctx, err, "gateway: error parsing target uri: "+fileInfo.Target), }, nil } if uri.Scheme == "webdav" { insecure, skipVerify := getGRPCConfig(req.Opaque) - return s.openFederatedShares(ctx, fileInfo.Target, req.ViewMode, insecure, skipVerify, resChild) + return s.openFederatedShares(ctx, fileInfo.Target, req.ViewMode, req.App, insecure, skipVerify, resChild) } res, err := s.Stat(ctx, &storageprovider.StatRequest{ Ref: req.Ref, }) if err != nil { - return &providerpb.OpenFileInAppProviderResponse{ + return &providerpb.OpenInAppResponse{ Status: status.NewInternal(ctx, err, "gateway: error calling Stat on the resource path for the app provider: "+req.Ref.GetPath()), }, nil } if res.Status.Code != rpc.Code_CODE_OK { err := status.NewErrorFromCode(res.Status.GetCode(), "gateway") - return &providerpb.OpenFileInAppProviderResponse{ + return &providerpb.OpenInAppResponse{ Status: status.NewInternal(ctx, err, "Stat failed on the resource path for the app provider: "+req.Ref.GetPath()), }, nil } fileInfo = res.Info } - return s.openLocalResources(ctx, fileInfo, req.ViewMode) + return s.openLocalResources(ctx, fileInfo, req.ViewMode, req.App) +} + +// This function is deprecated and will be removed in an upcoming PR +func (s *svc) OpenFileInAppProvider(ctx context.Context, req *gateway.OpenFileInAppProviderRequest) (*providerpb.OpenFileInAppProviderResponse, error) { + return nil, errtypes.NotSupported("Deprecated") } -func (s *svc) openFederatedShares(ctx context.Context, targetURL string, vm gateway.OpenFileInAppProviderRequest_ViewMode, - insecure, skipVerify bool, nameQueries ...string) (*providerpb.OpenFileInAppProviderResponse, error) { +func (s *svc) openFederatedShares(ctx context.Context, targetURL string, vm gateway.OpenInAppRequest_ViewMode, app gateway.OpenInAppRequest_App, + insecure, skipVerify bool, nameQueries ...string) (*providerpb.OpenInAppResponse, error) { log := appctx.GetLogger(ctx) targetURL, err := appendNameQuery(targetURL, nameQueries...) if err != nil { @@ -136,9 +141,10 @@ func (s *svc) openFederatedShares(ctx context.Context, targetURL string, vm gate Path: ep.filePath, }, } - appProviderReq := &gateway.OpenFileInAppProviderRequest{ + appProviderReq := &gateway.OpenInAppRequest{ Ref: ref, ViewMode: vm, + App: app, } meshProvider, err := s.GetInfoByDomain(ctx, &ocmprovider.GetInfoByDomainRequest{ @@ -153,12 +159,12 @@ func (s *svc) openFederatedShares(ctx context.Context, targetURL string, vm gate gatewayEP = s.Endpoint.Path } } - log.Debug().Msgf("Forwarding OpenFileInAppProvider request to: %s", gatewayEP) + log.Debug().Msgf("Forwarding OpenInApp request to: %s", gatewayEP) conn, err := getConn(gatewayEP, insecure, skipVerify) if err != nil { err = errors.Wrap(err, "gateway: error connecting to remote reva") - return &providerpb.OpenFileInAppProviderResponse{ + return &providerpb.OpenInAppResponse{ Status: status.NewInternal(ctx, err, "error error connecting to remote reva"), }, nil } @@ -167,20 +173,20 @@ func (s *svc) openFederatedShares(ctx context.Context, targetURL string, vm gate remoteCtx := token.ContextSetToken(context.Background(), ep.token) remoteCtx = metadata.AppendToOutgoingContext(remoteCtx, token.TokenHeader, ep.token) - res, err := gatewayClient.OpenFileInAppProvider(remoteCtx, appProviderReq) + res, err := gatewayClient.OpenInApp(remoteCtx, appProviderReq) if err != nil { log.Err(err).Msg("error reaching remote reva") - return nil, errors.Wrap(err, "gateway: error calling OpenFileInAppProvider") + return nil, errors.Wrap(err, "gateway: error calling OpenInApp") } return res, nil } func (s *svc) openLocalResources(ctx context.Context, ri *storageprovider.ResourceInfo, - vm gateway.OpenFileInAppProviderRequest_ViewMode) (*providerpb.OpenFileInAppProviderResponse, error) { + vm gateway.OpenInAppRequest_ViewMode, app gateway.OpenInAppRequest_App) (*providerpb.OpenInAppResponse, error) { accessToken, ok := token.ContextGetToken(ctx) if !ok || accessToken == "" { - return &providerpb.OpenFileInAppProviderResponse{ + return &providerpb.OpenInAppResponse{ Status: status.NewUnauthenticated(ctx, errtypes.InvalidCredentials("Access token is invalid or empty"), ""), }, nil } @@ -194,7 +200,7 @@ func (s *svc) openLocalResources(ctx context.Context, ri *storageprovider.Resour } else { st = status.NewInternal(ctx, err, "error searching for app provider") } - return &providerpb.OpenFileInAppProviderResponse{ + return &providerpb.OpenInAppResponse{ Status: st, }, nil } @@ -202,20 +208,21 @@ func (s *svc) openLocalResources(ctx context.Context, ri *storageprovider.Resour appProviderClient, err := pool.GetAppProviderClient(provider.Address) if err != nil { err = errors.Wrap(err, "gateway: error calling GetAppProviderClient") - return &providerpb.OpenFileInAppProviderResponse{ + return &providerpb.OpenInAppResponse{ Status: status.NewInternal(ctx, err, "error getting appprovider client"), }, nil } - appProviderReq := &providerpb.OpenFileInAppProviderRequest{ + appProviderReq := &providerpb.OpenInAppRequest{ ResourceInfo: ri, - ViewMode: providerpb.OpenFileInAppProviderRequest_ViewMode(vm), + ViewMode: providerpb.OpenInAppRequest_ViewMode(vm), + App: providerpb.OpenInAppRequest_App(app), AccessToken: accessToken, } - res, err := appProviderClient.OpenFileInAppProvider(ctx, appProviderReq) + res, err := appProviderClient.OpenInApp(ctx, appProviderReq) if err != nil { - return nil, errors.Wrap(err, "gateway: error calling OpenFileInAppProvider") + return nil, errors.Wrap(err, "gateway: error calling OpenInApp") } return res, nil