From 6d61530b7fc765243b3ee9a5edfc998f5e9312ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Pablo=20Villaf=C3=A1=C3=B1ez?= Date: Thu, 17 Oct 2024 11:45:19 +0200 Subject: [PATCH] feat: include a provider option to allow custom app names --- services/collaboration/pkg/config/app.go | 3 ++- services/collaboration/pkg/config/defaults/defaultconfig.go | 1 + services/collaboration/pkg/connector/fileconnector.go | 2 +- services/collaboration/pkg/service/grpc/v0/service.go | 4 ++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/services/collaboration/pkg/config/app.go b/services/collaboration/pkg/config/app.go index d5b4aa80fa2..377b28e3cc6 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"` + Provider string `yaml:"provider" env:"COLLABORATION_APP_PROVIDER" desc:"The provider of the 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 64810013a53..21709d47db1 100644 --- a/services/collaboration/pkg/config/defaults/defaultconfig.go +++ b/services/collaboration/pkg/config/defaults/defaultconfig.go @@ -22,6 +22,7 @@ func DefaultConfig() *config.Config { }, App: config.App{ Name: "Collabora", + Provider: "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 d63a4592ed1..e4d0fbadbbb 100644 --- a/services/collaboration/pkg/connector/fileconnector.go +++ b/services/collaboration/pkg/connector/fileconnector.go @@ -1147,7 +1147,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.Provider) { case "collabora": info = &fileinfo.Collabora{} case "onlyoffice": diff --git a/services/collaboration/pkg/service/grpc/v0/service.go b/services/collaboration/pkg/service/grpc/v0/service.go index 162d7947c43..3b29944563c 100644 --- a/services/collaboration/pkg/service/grpc/v0/service.go +++ b/services/collaboration/pkg/service/grpc/v0/service.go @@ -185,7 +185,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.Provider) == "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) @@ -273,7 +273,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.Provider) { case "collabora": q.Add("lang", lang) case "onlyoffice":