fix(userlog): name the creator of a removed ocm share

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 <jfd@butonic.de>
This commit is contained in:
Jörn Friedrich Dreyer committed 2026-12-04 16:49:00 +01:00
1 parent f435d3b50d
commit 190f3b3eef
3 files changed
+35 -8

No files matched your search

@@ -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())
}
+2 -2
View File
@@ -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:
@@ -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: `<img src=x onerror="alert(1)">`,
@@ -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,