graph: expose @libre.graph.tags on driveItems

This commit is contained in:
Dominik Schmidt
2026-07-11 12:32:09 +02:00
parent 61ef2d25d1
commit 9670cd90ee
2 changed files with 27 additions and 0 deletions

View File

@@ -24,6 +24,7 @@ import (
revactx "github.com/opencloud-eu/reva/v2/pkg/ctx"
"github.com/opencloud-eu/reva/v2/pkg/storagespace"
"github.com/opencloud-eu/reva/v2/pkg/tags"
"github.com/opencloud-eu/reva/v2/pkg/utils"
"github.com/opencloud-eu/opencloud/pkg/log"
@@ -460,6 +461,9 @@ func cs3ResourceToDriveItem(logger *log.Logger, publicBaseURL *url.URL, res *sto
m := res.GetArbitraryMetadata().GetMetadata()
driveItem.LibreGraphMeFollowing = libregraph.PtrBool(m[_favoriteMetadataKey] == "1")
if t := m["tags"]; t != "" {
driveItem.LibreGraphTags = tags.New(t).AsSlice()
}
}
return driveItem, nil

View File

@@ -294,6 +294,29 @@ var _ = Describe("Driveitems", func() {
Expect(res.Value[0].Audio).To(BeNil())
Expect(res.Value[0].Location).To(BeNil())
Expect(res.Value[0].LibreGraphMeFollowing).To(BeNil())
Expect(res.Value[0].LibreGraphTags).To(BeNil())
})
It("returns tags if metadata is available", func() {
gatewayClient.On("ListContainer", mock.Anything, mock.Anything).Return(&provider.ListContainerResponse{
Status: status.NewOK(ctx),
Infos: []*provider.ResourceInfo{
{
Type: provider.ResourceType_RESOURCE_TYPE_FILE,
Id: &provider.ResourceId{StorageId: "storageid", SpaceId: "spaceid", OpaqueId: "opaqueid"},
Etag: "etag",
Mtime: utils.TimeToTS(mtime),
ArbitraryMetadata: &provider.ArbitraryMetadata{
Metadata: map[string]string{
"tags": "marketing,important",
},
},
},
},
}, nil)
res := assertItemsList(1)
Expect(res.Value[0].GetLibreGraphTags()).To(ConsistOf("marketing", "important"))
})
It("returns the following state if metadata is available", func() {