From cd0831aa1041c4f03044b0fff7197e4f559ef45d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Duffeck?= Date: Wed, 11 Mar 2026 10:18:48 +0100 Subject: [PATCH] We no longer manage favorites via arbitrary metadata --- services/search/pkg/content/basic.go | 22 ++++++++++++++++++---- services/search/pkg/content/basic_test.go | 22 ++++++++++++++++++++++ 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/services/search/pkg/content/basic.go b/services/search/pkg/content/basic.go index 981acfd226..1499258c98 100644 --- a/services/search/pkg/content/basic.go +++ b/services/search/pkg/content/basic.go @@ -2,12 +2,11 @@ package content import ( "context" - "strings" + "encoding/json" "time" storageProvider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" "github.com/opencloud-eu/opencloud/pkg/log" - "github.com/opencloud-eu/reva/v2/pkg/storage/pkg/decomposedfs/node" "github.com/opencloud-eu/reva/v2/pkg/tags" "github.com/opencloud-eu/reva/v2/pkg/utils" ) @@ -34,8 +33,23 @@ func (b Basic) Extract(_ context.Context, ri *storageProvider.ResourceInfo) (Doc if t, ok := m["tags"]; ok { doc.Tags = tags.New(t).AsSlice() } - if t, ok := m[node.AllFavoritesKey]; ok && len(t) > 0 { - doc.Favorites = strings.Split(t, ",") + } + + if m := ri.Opaque.GetMap(); m != nil && m["favorites"] != nil { + favEntry := m["favorites"] + + switch favEntry.Decoder { + case "json": + favorites := []string{} + err := json.Unmarshal(favEntry.Value, &favorites) + if err != nil { + b.logger.Error().Err(err).Msg("failed to unmarshal favorites") + break + } + + doc.Favorites = favorites + default: + b.logger.Error().Msgf("unsupported decoder for favorites: %s", favEntry.Decoder) } } diff --git a/services/search/pkg/content/basic_test.go b/services/search/pkg/content/basic_test.go index 79ba9c3631..86832ed418 100644 --- a/services/search/pkg/content/basic_test.go +++ b/services/search/pkg/content/basic_test.go @@ -2,6 +2,7 @@ package content_test import ( "context" + "encoding/json" storageProvider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" cs3Types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1" @@ -86,5 +87,26 @@ var _ = Describe("Basic", func() { Expect(doc.Mtime).To(Equal(data.expect)) } }) + + It("extracts favorites", func() { + favorites := []string{"foo", "bar"} + favBytes, _ := json.Marshal(favorites) + + ri := &storageProvider.ResourceInfo{ + Opaque: &cs3Types.Opaque{ + Map: map[string]*cs3Types.OpaqueEntry{ + "favorites": { + Decoder: "json", + Value: favBytes, + }, + }, + }, + } + + doc, err := basic.Extract(ctx, ri) + Expect(err).To(BeNil()) + Expect(doc).ToNot(BeNil()) + Expect(doc.Favorites).To(Equal(favorites)) + }) }) })