Skip to content

Commit

Permalink
fix open by default app and expose default app
Browse files Browse the repository at this point in the history
  • Loading branch information
wkloucek committed Nov 10, 2021
1 parent 3fcbf5c commit 267d723
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 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
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 267d723

Please sign in to comment.