diff --git a/.drone.star b/.drone.star index 2764e87072..458c2a245e 100644 --- a/.drone.star +++ b/.drone.star @@ -2935,14 +2935,17 @@ def wopiCollaborationService(name): if name == "collabora": environment["COLLABORATION_APP_NAME"] = "Collabora" + environment["COLLABORATION_APP_PRODUCT"] = "Collabora" environment["COLLABORATION_APP_ADDR"] = "https://collabora:9980" environment["COLLABORATION_APP_ICON"] = "https://collabora:9980/favicon.ico" elif name == "onlyoffice": environment["COLLABORATION_APP_NAME"] = "OnlyOffice" + environment["COLLABORATION_APP_PRODUCT"] = "OnlyOffice" environment["COLLABORATION_APP_ADDR"] = "https://onlyoffice" environment["COLLABORATION_APP_ICON"] = "https://onlyoffice/web-apps/apps/documenteditor/main/resources/img/favicon.ico" elif name == "fakeoffice": environment["COLLABORATION_APP_NAME"] = "FakeOffice" + environment["COLLABORATION_APP_PRODUCT"] = "Microsoft" environment["COLLABORATION_APP_ADDR"] = "http://fakeoffice:8080" environment["COLLABORATION_WOPI_SRC"] = "http://%s:9300" % service_name diff --git a/services/collaboration/pkg/config/app.go b/services/collaboration/pkg/config/app.go index a2b2f7bb11..d22e0d43c5 100644 --- a/services/collaboration/pkg/config/app.go +++ b/services/collaboration/pkg/config/app.go @@ -2,7 +2,8 @@ package config // App defines the available app configuration. type App struct { - Name string `yaml:"name" env:"COLLABORATION_APP_NAME" desc:"The name of the app, either Collabora, OnlyOffice, Microsoft365 or MicrosoftOfficeOnline" introductionVersion:"6.0.0"` + Name string `yaml:"name" env:"COLLABORATION_APP_NAME" desc:"The name of the app" introductionVersion:"6.0.0"` + Product string `yaml:"product" env:"COLLABORATION_APP_PRODUCT" desc:"The WebOffice app, either Collabora, OnlyOffice, Microsoft365 or MicrosoftOfficeOnline" introductionVersion:"%%NEXT%%"` Description string `yaml:"description" env:"COLLABORATION_APP_DESCRIPTION" desc:"App description" introductionVersion:"6.0.0"` Icon string `yaml:"icon" env:"COLLABORATION_APP_ICON" desc:"Icon for the app" introductionVersion:"6.0.0"` LockName string `yaml:"lockname" env:"COLLABORATION_APP_LOCKNAME" desc:"Name for the app lock" introductionVersion:"6.0.0"` diff --git a/services/collaboration/pkg/config/defaults/defaultconfig.go b/services/collaboration/pkg/config/defaults/defaultconfig.go index d8bc4aab3c..8287fcd00f 100644 --- a/services/collaboration/pkg/config/defaults/defaultconfig.go +++ b/services/collaboration/pkg/config/defaults/defaultconfig.go @@ -24,6 +24,7 @@ func DefaultConfig() *config.Config { }, App: config.App{ Name: "Collabora", + Product: "Collabora", Description: "Open office documents with Collabora", Icon: "image-edit", LockName: "com.github.owncloud.collaboration", diff --git a/services/collaboration/pkg/connector/fileconnector.go b/services/collaboration/pkg/connector/fileconnector.go index b8dc73382d..073a18daf1 100644 --- a/services/collaboration/pkg/connector/fileconnector.go +++ b/services/collaboration/pkg/connector/fileconnector.go @@ -1172,7 +1172,7 @@ func (f *FileConnector) CheckFileInfo(ctx context.Context) (*ConnectorResponse, // This will help with the CI because we're using a "FakeOffice" app // for the wopi validator, which requires a Microsoft fileinfo var info fileinfo.FileInfo - switch strings.ToLower(f.cfg.App.Name) { + switch strings.ToLower(f.cfg.App.Product) { case "collabora": info = &fileinfo.Collabora{} case "onlyoffice": diff --git a/services/collaboration/pkg/connector/fileconnector_test.go b/services/collaboration/pkg/connector/fileconnector_test.go index f03ab5044b..b0f48586f5 100644 --- a/services/collaboration/pkg/connector/fileconnector_test.go +++ b/services/collaboration/pkg/connector/fileconnector_test.go @@ -48,6 +48,7 @@ var _ = Describe("FileConnector", func() { App: config.App{ LockName: "testName_for_unittests", // Only the LockName is used Name: "test", + Product: "Microsoft", }, Wopi: config.Wopi{ WopiSrc: "https://ocis.server.prv", @@ -1761,6 +1762,7 @@ var _ = Describe("FileConnector", func() { // change wopi app provider cfg.App.Name = "Collabora" + cfg.App.Product = "Collabora" expectedFileInfo := &fileinfo.Collabora{ OwnerID: "61616262636340637573746f6d496470", // hex of aabbcc@customIdp @@ -1834,6 +1836,7 @@ var _ = Describe("FileConnector", func() { // change wopi app provider cfg.App.Name = "Collabora" + cfg.App.Product = "Collabora" expectedFileInfo := &fileinfo.Collabora{ OwnerID: "61616262636340637573746f6d496470", // hex of aabbcc@customIdp @@ -1921,6 +1924,7 @@ var _ = Describe("FileConnector", func() { // change wopi app provider cfg.App.Name = "OnlyOffice" + cfg.App.Product = "OnlyOffice" response, err := fc.CheckFileInfo(ctx) Expect(err).ToNot(HaveOccurred()) diff --git a/services/collaboration/pkg/helpers/registration.go b/services/collaboration/pkg/helpers/registration.go index 0fa416bd4b..a6609fe20e 100644 --- a/services/collaboration/pkg/helpers/registration.go +++ b/services/collaboration/pkg/helpers/registration.go @@ -68,6 +68,7 @@ func RegisterAppProvider( Icon: cfg.App.Icon, Address: cfg.GRPC.Namespace + "." + cfg.Service.Name + "." + cfg.App.Name, MimeTypes: mimeTypes, + ProductName: cfg.App.Product, }, } gwc, err := gws.Next() diff --git a/services/collaboration/pkg/service/grpc/v0/service.go b/services/collaboration/pkg/service/grpc/v0/service.go index 5fa63b9ab6..74e12be130 100644 --- a/services/collaboration/pkg/service/grpc/v0/service.go +++ b/services/collaboration/pkg/service/grpc/v0/service.go @@ -188,7 +188,7 @@ func (s *Service) getAppUrl(fileExt string, viewMode appproviderv1beta1.ViewMode // prioritize view action if possible appURL := s.getAppUrlFor("view", fileExt) - if strings.ToLower(s.config.App.Name) == "collabora" { + if strings.ToLower(s.config.App.Product) == "collabora" { // collabora provides only one action per extension. usual options // are "view" (checked above), "edit" or "view_comment" (this last one // is exclusive of collabora) @@ -276,7 +276,7 @@ func (s *Service) addQueryToURL(baseURL string, req *appproviderv1beta1.OpenInAp } if lang != "" { - switch strings.ToLower(s.config.App.Name) { + switch strings.ToLower(s.config.App.Product) { case "collabora": q.Add("lang", lang) case "onlyoffice": diff --git a/services/collaboration/pkg/service/grpc/v0/service_test.go b/services/collaboration/pkg/service/grpc/v0/service_test.go index 636a9f4acf..1c2359ad85 100644 --- a/services/collaboration/pkg/service/grpc/v0/service_test.go +++ b/services/collaboration/pkg/service/grpc/v0/service_test.go @@ -147,6 +147,7 @@ var _ = Describe("Discovery", func() { cfg.Wopi.Secret = "my_supa_secret" cfg.Wopi.DisableChat = disableChat cfg.App.Name = appName + cfg.App.Product = appName myself := &userv1beta1.User{ Id: &userv1beta1.UserId{ @@ -333,6 +334,7 @@ var _ = Describe("Discovery", func() { cfg.Wopi.WopiSrc = "htttps://wopiserver.test.prv" cfg.Wopi.Secret = "my_supa_secret" cfg.App.Name = "OnlyOffice" + cfg.App.Product = "OnlyOffice" myself := &userv1beta1.User{ Id: &userv1beta1.UserId{