Skip to content

Commit

Permalink
fix open by default app and expose default app (#2230)
Browse files Browse the repository at this point in the history
  • Loading branch information
wkloucek authored Nov 10, 2021
1 parent 2ca63c8 commit 63cd968
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
7 changes: 7 additions & 0 deletions changelog/unreleased/fix-default-app-handling.md
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
28 changes: 19 additions & 9 deletions pkg/app/registry/static/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,14 @@ func (m *manager) ListSupportedMimeTypes(ctx context.Context) ([]*registrypb.Mim
mime := pair.Value.(*mimeTypeConfig)

res = append(res, &registrypb.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,
})

}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 63cd968

Please sign in to comment.