From 612f31bcbb1a58a382502f63591425cc9c599519 Mon Sep 17 00:00:00 2001 From: Roman Perekhod Date: Wed, 8 May 2024 16:57:44 +0200 Subject: [PATCH 1/2] fixed the collaboration service GRPC namespace --- changelog/unreleased/fix-collaboration-registry.md | 5 +++++ services/collaboration/pkg/helpers/registration.go | 4 ++-- services/collaboration/pkg/server/http/server.go | 3 +-- 3 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 changelog/unreleased/fix-collaboration-registry.md diff --git a/changelog/unreleased/fix-collaboration-registry.md b/changelog/unreleased/fix-collaboration-registry.md new file mode 100644 index 000000000..27d29a3db --- /dev/null +++ b/changelog/unreleased/fix-collaboration-registry.md @@ -0,0 +1,5 @@ +Bugfix: Fix collaboration registry setting + +Fixed the collaboration service GRPC namespace + +https://github.com/owncloud/ocis/pull/9105 diff --git a/services/collaboration/pkg/helpers/registration.go b/services/collaboration/pkg/helpers/registration.go index 49fbfab28..c5e375dba 100644 --- a/services/collaboration/pkg/helpers/registration.go +++ b/services/collaboration/pkg/helpers/registration.go @@ -18,7 +18,7 @@ import ( // There are no explicit requirements for the context, and it will be passed // without changes to the underlying RegisterService method. func RegisterOcisService(ctx context.Context, cfg *config.Config, logger log.Logger) error { - svc := registry.BuildGRPCService(cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.GRPC.Addr, "0.0.0") + svc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.GRPC.Addr, "0.0.0") return registry.RegisterService(ctx, svc, logger) } @@ -61,7 +61,7 @@ func RegisterAppProvider( Name: cfg.App.Name, Description: cfg.App.Description, Icon: cfg.App.Icon, - Address: cfg.Service.Name, + Address: cfg.GRPC.Namespace + "." + cfg.Service.Name, MimeTypes: mimeTypes, }, } diff --git a/services/collaboration/pkg/server/http/server.go b/services/collaboration/pkg/server/http/server.go index 1e8609f90..c24c2acd1 100644 --- a/services/collaboration/pkg/server/http/server.go +++ b/services/collaboration/pkg/server/http/server.go @@ -2,7 +2,6 @@ package http import ( "fmt" - stdhttp "net/http" "github.com/go-chi/chi/v5" @@ -26,7 +25,7 @@ func Server(opts ...Option) (http.Service, error) { http.TLSConfig(options.Config.HTTP.TLS), http.Logger(options.Logger), http.Namespace(options.Config.HTTP.Namespace), - http.Name(options.Config.Service.Name), + http.Name("wopi"), http.Version(version.GetString()), http.Address(options.Config.HTTP.BindAddr), http.Context(options.Context), From fb43919e0aa1b3568b377fe22ee29029030606ad Mon Sep 17 00:00:00 2001 From: Roman Perekhod Date: Thu, 9 May 2024 23:12:20 +0200 Subject: [PATCH 2/2] fixed OpenInApp URL --- .../collaboration/pkg/service/grpc/v0/service.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/services/collaboration/pkg/service/grpc/v0/service.go b/services/collaboration/pkg/service/grpc/v0/service.go index 28d27b47f..cbdb603ff 100644 --- a/services/collaboration/pkg/service/grpc/v0/service.go +++ b/services/collaboration/pkg/service/grpc/v0/service.go @@ -4,6 +4,7 @@ import ( "context" "crypto/sha256" "encoding/hex" + "fmt" "net/url" "path" "strconv" @@ -99,6 +100,15 @@ func (s *Service) OpenInApp( editAppURL = url } } + if editAppURL == "" && viewAppURL == "" { + err := fmt.Errorf("OpenInApp: neither edit nor view app url found") + s.logger.Error(). + Err(err). + Str("FileReference", providerFileRef.String()). + Str("ViewMode", req.GetViewMode().String()). + Str("Requester", user.GetId().String()).Send() + return nil, err + } if editAppURL == "" { // assuming that an view action is always available in the /hosting/discovery manifest @@ -107,6 +117,10 @@ func (s *Service) OpenInApp( // there is no known case of supporting edit only without view editAppURL = viewAppURL } + if viewAppURL == "" { + // the URL of the end-user application in view mode when different (defaults to edit mod URL) + viewAppURL = editAppURL + } wopiSrcURL := url.URL{ Scheme: s.config.HTTP.Scheme,