From 8b71835e3ece0b3aa0fd1e9eecb372baa79421b4 Mon Sep 17 00:00:00 2001 From: Willy Kloucek Date: Mon, 11 Oct 2021 14:10:11 +0200 Subject: [PATCH 1/2] remove excess info from the http list app providers endpoint --- .../unreleased/app-provider-remove-excess-info.md | 10 ++++++++++ internal/http/services/appprovider/appprovider.go | 7 +++++++ pkg/app/registry/static/static.go | 13 +++++-------- 3 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 changelog/unreleased/app-provider-remove-excess-info.md diff --git a/changelog/unreleased/app-provider-remove-excess-info.md b/changelog/unreleased/app-provider-remove-excess-info.md new file mode 100644 index 0000000000..d26fbdf94c --- /dev/null +++ b/changelog/unreleased/app-provider-remove-excess-info.md @@ -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 diff --git a/internal/http/services/appprovider/appprovider.go b/internal/http/services/appprovider/appprovider.go index e4dc55d57d..d23be67012 100644 --- a/internal/http/services/appprovider/appprovider.go +++ b/internal/http/services/appprovider/appprovider.go @@ -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 { diff --git a/pkg/app/registry/static/static.go b/pkg/app/registry/static/static.go index 8f800e17a1..2380f45e9c 100644 --- a/pkg/app/registry/static/static.go +++ b/pkg/app/registry/static/static.go @@ -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" @@ -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 } } From 3bb0ee0e32e40d808af1572bfc6d1cc630ed02f1 Mon Sep 17 00:00:00 2001 From: Willy Kloucek Date: Mon, 11 Oct 2021 15:16:49 +0200 Subject: [PATCH 2/2] remove provider filter from http endpoint to registry --- internal/grpc/services/appregistry/appregistry.go | 7 +++++++ internal/http/services/appprovider/appprovider.go | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/grpc/services/appregistry/appregistry.go b/internal/grpc/services/appregistry/appregistry.go index 035f240029..4b8c08f6d7 100644 --- a/internal/grpc/services/appregistry/appregistry.go +++ b/internal/grpc/services/appregistry/appregistry.go @@ -151,6 +151,13 @@ func (s *svc) ListSupportedMimeTypes(ctx context.Context, req *registrypb.ListSu }, nil } + // hide mimetypes for app providers + for _, mime := range mimeTypes { + for _, app := range mime.AppProviders { + app.MimeTypes = nil + } + } + res := ®istrypb.ListSupportedMimeTypesResponse{ Status: status.NewOK(ctx), MimeTypes: mimeTypes, diff --git a/internal/http/services/appprovider/appprovider.go b/internal/http/services/appprovider/appprovider.go index d23be67012..e4dc55d57d 100644 --- a/internal/http/services/appprovider/appprovider.go +++ b/internal/http/services/appprovider/appprovider.go @@ -245,13 +245,6 @@ 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 {