diff --git a/services/graph/pkg/service/v0/sharedwithme.go b/services/graph/pkg/service/v0/sharedwithme.go index 261de483c34..d9e0301e321 100644 --- a/services/graph/pkg/service/v0/sharedwithme.go +++ b/services/graph/pkg/service/v0/sharedwithme.go @@ -92,7 +92,6 @@ func (g Graph) cs3ReceivedSharesToDriveItems(ctx context.Context, receivedShares group.Go(func() error { var err error // redeclare - resourceID := receivedShares[0].GetShare().GetResourceId() shareStat, err := doStat(receivedShares[0].GetShare().GetResourceId()) if shareStat == nil || err != nil { return err @@ -100,17 +99,17 @@ func (g Graph) cs3ReceivedSharesToDriveItems(ctx context.Context, receivedShares driveItem := libregraph.NewDriveItem() - // The id of the driveItem will be the composed of the StorageID and the SpaceID of the sharestorage - // appended with the ResourceID of the shared resource - // '$!::' - driveItem.SetId(storagespace.FormatResourceID(storageprovider.ResourceId{ - StorageId: utils.ShareStorageProviderID, - OpaqueId: resourceID.GetStorageId() + ":" + resourceID.GetSpaceId() + ":" + resourceID.GetOpaqueId(), - SpaceId: utils.ShareStorageSpaceID, - })) permissions := make([]libregraph.Permission, 0, len(receivedShares)) + var oldestReceivedShare *collaboration.ReceivedShare for _, receivedShare := range receivedShares { + switch { + case oldestReceivedShare == nil: + fallthrough + case utils.TSToTime(receivedShare.GetShare().GetCtime()).Before(utils.TSToTime(oldestReceivedShare.GetShare().GetCtime())): + oldestReceivedShare = receivedShare + } + permission, err := g.cs3ReceivedShareToLibreGraphPermissions(ctx, receivedShare) if err != nil { return err @@ -150,6 +149,15 @@ func (g Graph) cs3ReceivedSharesToDriveItems(ctx context.Context, receivedShares } + // The id of the driveItem will be the composed of the StorageID and the SpaceID of the sharestorage + // appended with the ShareID of the oldest shared that exists for this resource + // '$!::' + driveItem.SetId(storagespace.FormatResourceID(storageprovider.ResourceId{ + StorageId: utils.ShareStorageProviderID, + OpaqueId: oldestReceivedShare.GetShare().GetId().GetOpaqueId(), + SpaceId: utils.ShareStorageSpaceID, + })) + if !driveItem.HasUIHidden() { driveItem.SetUIHidden(false) }