From 4792071d3d3600bac58e494dc13cf34605e15db0 Mon Sep 17 00:00:00 2001 From: Ralf Haferkamp Date: Thu, 7 Nov 2024 12:00:38 +0100 Subject: [PATCH] fix(graph): Use the correct opaqueId when Statting OCM shares File shares need to use the base64 encoded path as the opaqueID, while for folder shares the base64 encode '/' should work. Fixes #10495 --- changelog/unreleased/fix-ocm-file-preview.md | 7 +++++++ services/graph/pkg/service/v0/utils.go | 12 ++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 changelog/unreleased/fix-ocm-file-preview.md diff --git a/changelog/unreleased/fix-ocm-file-preview.md b/changelog/unreleased/fix-ocm-file-preview.md new file mode 100644 index 00000000000..39835ae918e --- /dev/null +++ b/changelog/unreleased/fix-ocm-file-preview.md @@ -0,0 +1,7 @@ +Bugfix: Fixed `sharedWithMe` response for OCM shares + +OCM shares returned in the `sharedWithMe` response did not have the `mimeType` property +populated correctly. + +https://github.com/owncloud/ocis/pull/10501 +https://github.com/owncloud/ocis/issues/10495 diff --git a/services/graph/pkg/service/v0/utils.go b/services/graph/pkg/service/v0/utils.go index 02a15dea105..a5480536aca 100644 --- a/services/graph/pkg/service/v0/utils.go +++ b/services/graph/pkg/service/v0/utils.go @@ -2,6 +2,7 @@ package svc import ( "context" + "encoding/base64" "encoding/json" "io" "net/http" @@ -538,14 +539,21 @@ func cs3ReceivedOCMSharesToDriveItems(ctx context.Context, group.Go(func() error { var err error // redeclare + + // for OCM shares the opaqueID is the '/' for shared directories and '/filename' for + // file shares + resOpaqueID := "/" + if receivedShares[0].GetResourceType() == storageprovider.ResourceType_RESOURCE_TYPE_FILE { + resOpaqueID += receivedShares[0].GetName() + } + shareStat, err := gatewayClient.Stat(ctx, &storageprovider.StatRequest{ Ref: &storageprovider.Reference{ ResourceId: &storageprovider.ResourceId{ // TODO maybe the reference is wrong StorageId: utils.OCMStorageProviderID, SpaceId: receivedShares[0].GetId().GetOpaqueId(), - OpaqueId: "", // in OCM resources the opaque id is the base64 encoded path - //OpaqueId: maybe ? receivedShares[0].GetId().GetOpaqueId(), + OpaqueId: base64.StdEncoding.EncodeToString([]byte(resOpaqueID)), }, }, })