From 36eff3b280f8e6748fe5e973ae4728d79894020d Mon Sep 17 00:00:00 2001 From: Ralf Haferkamp Date: Tue, 30 Jan 2024 17:31:21 +0100 Subject: [PATCH] graph/sharedWithMe: Fix 'createdBy' attribute for resources from project spaces Don't return a meaningless userid anymore for shares created from files or directories in a project space. These resources don't have a real owner. Fixes: #8314 --- services/graph/pkg/service/v0/sharedwithme.go | 2 +- services/graph/pkg/service/v0/sharedwithme_test.go | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/services/graph/pkg/service/v0/sharedwithme.go b/services/graph/pkg/service/v0/sharedwithme.go index a0f907d4f1..261de483c3 100644 --- a/services/graph/pkg/service/v0/sharedwithme.go +++ b/services/graph/pkg/service/v0/sharedwithme.go @@ -226,7 +226,7 @@ func (g Graph) cs3ReceivedSharesToDriveItems(ctx context.Context, receivedShares remoteItem.SetSize(s) } - if userID := shareStat.GetInfo().GetOwner(); userID != nil { + if userID := shareStat.GetInfo().GetOwner(); userID != nil && userID.Type != cs3User.UserType_USER_TYPE_SPACE_OWNER { identity, err := g.cs3UserIdToIdentity(ctx, userID) if err != nil { // TODO: define a proper error behavior here. We don't diff --git a/services/graph/pkg/service/v0/sharedwithme_test.go b/services/graph/pkg/service/v0/sharedwithme_test.go index a8f235b04b..7ba445f90d 100644 --- a/services/graph/pkg/service/v0/sharedwithme_test.go +++ b/services/graph/pkg/service/v0/sharedwithme_test.go @@ -387,8 +387,7 @@ var _ = Describe("SharedWithMe", func() { jsonData := gjson.Get(tape.Body.String(), "value.0.createdBy") - Expect(jsonData.Get("user.displayName").String()).To(Equal("")) - Expect(jsonData.Get("user.id").String()).To(Equal(ownerID.OpaqueId)) + Expect(jsonData.String()).To(Equal("")) jsonData = gjson.Get(tape.Body.String(), "value.0.remoteItem.permissions.0.invitation.invitedBy.user") Expect(jsonData.Get("displayName").String()).To(Equal(getUserResponseShareCreator.User.DisplayName))