Skip to content

Commit

Permalink
Merge pull request #10335 from owncloud/collaboration_provider_config
Browse files Browse the repository at this point in the history
feat: include a provider option to allow custom app names
  • Loading branch information
micbar authored Nov 5, 2024
2 parents 8a4523b + ff8d674 commit 786efd3
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion services/collaboration/pkg/config/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion services/collaboration/pkg/connector/fileconnector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
4 changes: 4 additions & 0 deletions services/collaboration/pkg/connector/fileconnector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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())
Expand Down
1 change: 1 addition & 0 deletions services/collaboration/pkg/helpers/registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions services/collaboration/pkg/service/grpc/v0/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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":
Expand Down
2 changes: 2 additions & 0 deletions services/collaboration/pkg/service/grpc/v0/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down

0 comments on commit 786efd3

Please sign in to comment.