Skip to content

Commit

Permalink
remove excess info from the http list app providers endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
wkloucek committed Oct 11, 2021
1 parent 26bc95f commit 8b71835
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
10 changes: 10 additions & 0 deletions changelog/unreleased/app-provider-remove-excess-info.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Bugfix: Remove excess info from the http list app providers endpoint

We've removed excess info from the http list app providers endpoint.
The app provider section contained all mime types supported by a certain app provider,
which led to a very big JSON payload and since they are not used they have been removed again.
Mime types not on the mime type configuration list always had `application/octet-stream` as a file extension and `APPLICATION/OCTET-STREAM file` as name and description. Now these information are just omitted.

https://github.com/cs3org/reva/pull/2149
https://github.com/owncloud/ocis/pull/2603
https://github.com/cs3org/reva/pull/2138
7 changes: 7 additions & 0 deletions internal/http/services/appprovider/appprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,13 @@ func (s *svc) handleList(w http.ResponseWriter, r *http.Request) {
return
}

// hide mimetypes for app providers
for _, mime := range listRes.MimeTypes {
for _, app := range mime.AppProviders {
app.MimeTypes = nil
}
}

res := filterAppsByUserAgent(listRes.MimeTypes, r.UserAgent())
js, err := json.Marshal(map[string]interface{}{"mime-types": res})
if err != nil {
Expand Down
13 changes: 5 additions & 8 deletions pkg/app/registry/static/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"github.com/cs3org/reva/pkg/app"
"github.com/cs3org/reva/pkg/app/registry/registry"
"github.com/cs3org/reva/pkg/errtypes"
"github.com/cs3org/reva/pkg/mime"
"github.com/mitchellh/mapstructure"
"github.com/rs/zerolog/log"
orderedmap "github.com/wk8/go-ordered-map"
Expand Down Expand Up @@ -265,14 +264,12 @@ func (m *manager) SetDefaultProviderForMimeType(ctx context.Context, mimeType st
}

func dummyMimeType(m string, apps []*registrypb.ProviderInfo) *mimeTypeConfig {
ext := mime.Detect(false, m)

return &mimeTypeConfig{
MimeType: m,
apps: apps,
Extension: ext,
Name: fmt.Sprintf("%s file", strings.ToUpper(ext)),
Description: fmt.Sprintf("%s file", strings.ToUpper(ext)),
MimeType: m,
apps: apps,
//Extension: "", // there is no meaningful general extension, so omit it
//Name: "", // there is no meaningful general name, so omit it
//Description: "", // there is no meaningful general description, so omit it
}
}

Expand Down

0 comments on commit 8b71835

Please sign in to comment.