From 190f3b3eef8e8627ffb135d33e2503816939d75a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Fri, 4 Dec 2026 16:49:00 +0100 Subject: [PATCH] fix(userlog): name the creator of a removed ocm share MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The delete event of an ocm share carries the owner of the share as Sharer. For a share from a project space that is the space owner, so the unshare notification named the wrong person. We now use the new Executant of both ocm events, which is the creator of the share. The OCM unshare notification does not say who removed the share, so the creator is the closest we know. related: https://github.com/opencloud-eu/reva/pull/1075 Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Jörn Friedrich Dreyer --- .../userlog/pkg/service/consumer/service.go | 4 +-- services/userlog/pkg/service/conversion.go | 4 +-- .../userlog/pkg/service/conversion_test.go | 35 ++++++++++++++++--- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/services/userlog/pkg/service/consumer/service.go b/services/userlog/pkg/service/consumer/service.go index 2aaa0b44e1..b4d74fa40b 100644 --- a/services/userlog/pkg/service/consumer/service.go +++ b/services/userlog/pkg/service/consumer/service.go @@ -163,10 +163,10 @@ func (s *Service) processEvent(event events.Event) { // ocm share related, the grantee is always a local user case events.OCMCoreShareCreated: - executant = e.Sharer + executant = e.Executant users = append(users, e.GranteeUserID.GetOpaqueId()) case events.OCMCoreShareDelete: - executant = e.Sharer + executant = e.Executant users = append(users, e.Grantee.GetOpaqueId()) } diff --git a/services/userlog/pkg/service/conversion.go b/services/userlog/pkg/service/conversion.go index 1934a1594c..fed7dfa51e 100644 --- a/services/userlog/pkg/service/conversion.go +++ b/services/userlog/pkg/service/conversion.go @@ -134,9 +134,9 @@ func (c *Converter) ConvertEvent(eventid string, event any) (OC10Notification, e // ocm share related case events.OCMCoreShareCreated: - return c.ocmShareMessage(eventid, ocmShareCreatedTemplates, ev.Sharer, ev.GranteeUserID, ev.ShareID, ev.ResourceName, utils.TSToTime(ev.CTime)) + return c.ocmShareMessage(eventid, ocmShareCreatedTemplates, ev.Executant, ev.GranteeUserID, ev.ShareID, ev.ResourceName, utils.TSToTime(ev.CTime)) case events.OCMCoreShareDelete: - return c.ocmShareMessage(eventid, ocmShareRemovedTemplates, ev.Sharer, ev.Grantee, ev.ShareID, ev.ResourceName, utils.TSToTime(ev.CTime)) + return c.ocmShareMessage(eventid, ocmShareRemovedTemplates, ev.Executant, ev.Grantee, ev.ShareID, ev.ResourceName, utils.TSToTime(ev.CTime)) // misc case ocEvents.ResourceMention: diff --git a/services/userlog/pkg/service/conversion_test.go b/services/userlog/pkg/service/conversion_test.go index 2722b68a7a..048166b0fb 100644 --- a/services/userlog/pkg/service/conversion_test.go +++ b/services/userlog/pkg/service/conversion_test.go @@ -64,7 +64,7 @@ var _ = Describe("Converter", func() { n, err := converter.ConvertEvent("eventid", events.OCMCoreShareCreated{ ShareID: "shareid", - Sharer: sharer, + Executant: sharer, GranteeUserID: grantee, ItemID: "remote-item-id", ResourceName: "relativity", @@ -87,7 +87,7 @@ var _ = Describe("Converter", func() { n, err := converter.ConvertEvent("eventid", events.OCMCoreShareDelete{ ShareID: "shareid", - Sharer: sharer, + Executant: sharer, Grantee: grantee, ResourceName: "relativity", CTime: ctime, @@ -101,6 +101,33 @@ var _ = Describe("Converter", func() { Expect(n.MessageDetails["resource"]).To(Equal(map[string]string{"name": "relativity"})) }) + It("names the creator of the share, not the owner, when the share is removed", func() { + // e.g. a share from a project space, which is owned by the space owner + owner := &user.UserId{ + Type: user.UserType_USER_TYPE_FEDERATED, + OpaqueId: "0b4ea7ac-07e2-4bd4-9cd5-bd8bf3e4b6a1@https://remote.example.org", + Idp: "remote.example.org", + } + gatewayClient.On("GetAcceptedUser", mock.Anything, mock.MatchedBy(func(req *invitepb.GetAcceptedUserRequest) bool { + return req.GetRemoteUserId().GetOpaqueId() == sharer.GetOpaqueId() + })).Return(&invitepb.GetAcceptedUserResponse{ + Status: &rpc.Status{Code: rpc.Code_CODE_OK}, + RemoteUser: &user.User{Id: sharer, Username: "einstein", DisplayName: "Albert Einstein"}, + }, nil) + + n, err := converter.ConvertEvent("eventid", events.OCMCoreShareDelete{ + ShareID: "shareid", + Executant: sharer, + Sharer: owner, + Grantee: grantee, + ResourceName: "relativity", + CTime: ctime, + }) + Expect(err).ToNot(HaveOccurred()) + Expect(n.Message).To(Equal("Albert Einstein unshared relativity with you")) + Expect(n.UserName).To(Equal("einstein")) + }) + It("does not name a provider that is no hostname", func() { gatewayClient.On("GetAcceptedUser", mock.Anything, mock.Anything).Return(&invitepb.GetAcceptedUserResponse{ Status: &rpc.Status{Code: rpc.Code_CODE_NOT_FOUND}, @@ -108,7 +135,7 @@ var _ = Describe("Converter", func() { n, err := converter.ConvertEvent("eventid", events.OCMCoreShareCreated{ ShareID: "shareid", - Sharer: &user.UserId{ + Executant: &user.UserId{ Type: user.UserType_USER_TYPE_FEDERATED, OpaqueId: "4c510ada-c86b-4815-8820-42cdf82c3d51@https://remote.example.org", Idp: ``, @@ -128,7 +155,7 @@ var _ = Describe("Converter", func() { for range 2 { n, err := converter.ConvertEvent("eventid", events.OCMCoreShareDelete{ ShareID: "shareid", - Sharer: sharer, + Executant: sharer, Grantee: grantee, ResourceName: "relativity", CTime: ctime,