From 63cd96849ff22995752d393c357854dcd503d0b5 Mon Sep 17 00:00:00 2001 From: Willy Kloucek <34452982+wkloucek@users.noreply.github.com> Date: Wed, 10 Nov 2021 11:42:28 +0100 Subject: [PATCH] fix open by default app and expose default app (#2230) --- .../unreleased/fix-default-app-handling.md | 7 +++++ go.mod | 2 +- go.sum | 4 +++ pkg/app/registry/static/static.go | 28 +++++++++++++------ 4 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 changelog/unreleased/fix-default-app-handling.md diff --git a/changelog/unreleased/fix-default-app-handling.md b/changelog/unreleased/fix-default-app-handling.md new file mode 100644 index 0000000000..e747f819f9 --- /dev/null +++ b/changelog/unreleased/fix-default-app-handling.md @@ -0,0 +1,7 @@ +Bugfix: Fix open by default app and expose default app + +We've fixed the open by default app name behaviour which previously only worked, if the default app was configured by the provider address. +We also now expose the default app on the `/app/list` endpoint to clients. + +https://github.com/cs3org/reva/issues/2230 +https://github.com/cs3org/cs3apis/pull/157 diff --git a/go.mod b/go.mod index 064c4e03be..ebe166f541 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/cheggaaa/pb v1.0.29 github.com/coreos/go-oidc v2.2.1+incompatible github.com/cs3org/cato v0.0.0-20200828125504-e418fc54dd5e - github.com/cs3org/go-cs3apis v0.0.0-20211018122138-391b29bd7803 + github.com/cs3org/go-cs3apis v0.0.0-20211104090126-8e972dca8304 github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8 github.com/eventials/go-tus v0.0.0-20200718001131-45c7ec8f5d59 github.com/gdexlab/go-render v1.0.1 diff --git a/go.sum b/go.sum index e5c3b36bdf..7340c9b50f 100644 --- a/go.sum +++ b/go.sum @@ -111,8 +111,12 @@ github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/cs3org/cato v0.0.0-20200828125504-e418fc54dd5e h1:tqSPWQeueWTKnJVMJffz4pz0o1WuQxJ28+5x5JgaHD8= github.com/cs3org/cato v0.0.0-20200828125504-e418fc54dd5e/go.mod h1:XJEZ3/EQuI3BXTp/6DUzFr850vlxq11I6satRtz0YQ4= +github.com/cs3org/go-cs3apis v0.0.0-20210325133324-32b03d75a535 h1:555D8A3ddKqb4OyK9v5mdphw2zDLWKGXOkcnf1RQwTA= +github.com/cs3org/go-cs3apis v0.0.0-20210325133324-32b03d75a535/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY= github.com/cs3org/go-cs3apis v0.0.0-20211018122138-391b29bd7803 h1:R/6llgTNKxQQ7GaSTgFn6Fp8N50wIlagmdR7WY5LntM= github.com/cs3org/go-cs3apis v0.0.0-20211018122138-391b29bd7803/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY= +github.com/cs3org/go-cs3apis v0.0.0-20211104090126-8e972dca8304 h1:e/nIPR518vyvrulo9goAZTtYD6gFfu/2/9MDe6mTGcw= +github.com/cs3org/go-cs3apis v0.0.0-20211104090126-8e972dca8304/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY= github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8 h1:Z9lwXumT5ACSmJ7WGnFl+OMLLjpz5uR2fyz7dC255FI= github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8/go.mod h1:4abs/jPXcmJzYoYGF91JF9Uq9s/KL5n1jvFDix8KcqY= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/pkg/app/registry/static/static.go b/pkg/app/registry/static/static.go index dcce6e2bdc..5c803e017a 100644 --- a/pkg/app/registry/static/static.go +++ b/pkg/app/registry/static/static.go @@ -227,13 +227,14 @@ func (m *manager) ListSupportedMimeTypes(ctx context.Context) ([]*registrypb.Mim mime := pair.Value.(*mimeTypeConfig) res = append(res, ®istrypb.MimeTypeInfo{ - MimeType: mime.MimeType, - Ext: mime.Extension, - Name: mime.Name, - Description: mime.Description, - Icon: mime.Icon, - AppProviders: mime.apps, - AllowCreation: mime.AllowCreation, + MimeType: mime.MimeType, + Ext: mime.Extension, + Name: mime.Name, + Description: mime.Description, + Icon: mime.Icon, + AppProviders: mime.apps, + AllowCreation: mime.AllowCreation, + DefaultApplication: mime.DefaultApp, }) } @@ -300,11 +301,20 @@ func (m *manager) GetDefaultProviderForMimeType(ctx context.Context, mimeType st m.RLock() defer m.RUnlock() - mime, ok := m.mimetypes.Get(mimeType) + mimeInterface, ok := m.mimetypes.Get(mimeType) if ok { - if p, ok := m.providers[mime.(*mimeTypeConfig).DefaultApp]; ok { + mime := mimeInterface.(*mimeTypeConfig) + // default by provider address + if p, ok := m.providers[mime.DefaultApp]; ok { return p, nil } + + // default by provider name + for _, p := range m.providers { + if p.Name == mime.DefaultApp { + return p, nil + } + } } return nil, errtypes.NotFound("default application provider not set for mime type " + mimeType)