Merge pull request #10335 from owncloud/collaboration_provider_config

feat: include a provider option to allow custom app names
This commit is contained in:
Michael Barz
2024-11-05 14:18:50 +01:00
committed by GitHub
8 changed files with 16 additions and 4 deletions

View File

@@ -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

View File

@@ -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"`

View File

@@ -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",

View File

@@ -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":

View File

@@ -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())

View File

@@ -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()

View File

@@ -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":

View File

@@ -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{