Skip to content

Commit

Permalink
fix(graph): Use the correct opaqueId when Statting OCM shares
Browse files Browse the repository at this point in the history
File shares need to use the base64 encoded path as the opaqueID, while
for folder shares the base64 encode '/' should work.

Fixes owncloud#10495
  • Loading branch information
rhafer committed Nov 7, 2024
1 parent 75cba42 commit d3afc00
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
8 changes: 8 additions & 0 deletions changelog/unreleased/fix-ocm-file-preview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Bugfix: Fixed `sharedWithMe` response for OCM shares

OCM shares retunred in the `sharedWithMe` response did not have the `mimeType` property
populated correctly.


https://github.com/owncloud/ocis/pull/xxxxx
https://github.com/owncloud/ocis/issues/10495
12 changes: 10 additions & 2 deletions services/graph/pkg/service/v0/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package svc

import (
"context"
"encoding/base64"
"encoding/json"
"io"
"net/http"
Expand Down Expand Up @@ -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)),
},
},
})
Expand Down

0 comments on commit d3afc00

Please sign in to comment.