Merge pull request #5873 from kobergj/NoNotificationForOwnActions

No Notifications for own actions
This commit is contained in:
kobergj
2023-03-21 16:26:19 +01:00
committed by GitHub
4 changed files with 31 additions and 7 deletions

View File

@@ -1,3 +1,3 @@
# The test runner source for UI tests
WEB_COMMITID=619dfc499f8d975200a13215acdd365dd9849c1f
WEB_BRANCH=master
WEB_COMMITID=abb16c5fdf7b7726969d2afa05aec72d017cca5a
WEB_BRANCH=changeNotificationTest

View File

@@ -0,0 +1,5 @@
Enhancement: No Notifications for own actions
Don't send notifications on space events when the user has executed them herself.
https://github.com/owncloud/ocis/pull/5871

View File

@@ -83,8 +83,9 @@ func (ul *UserlogService) MemorizeEvents(ch <-chan events.Event) {
// for each event we need to:
// I) find users eligible to receive the event
var (
users []string
err error
users []string
executant *user.UserId
err error
)
switch e := event.Event.(type) {
@@ -92,22 +93,28 @@ func (ul *UserlogService) MemorizeEvents(ch <-chan events.Event) {
err = errors.New("unhandled event")
// space related // TODO: how to find spaceadmins?
case events.SpaceDisabled:
executant = e.Executant
users, err = ul.findSpaceMembers(ul.impersonate(e.Executant), e.ID.GetOpaqueId(), viewer)
case events.SpaceDeleted:
executant = e.Executant
for u := range e.FinalMembers {
users = append(users, u)
}
case events.SpaceShared:
executant = e.Executant
users, err = ul.resolveID(ul.impersonate(e.Executant), e.GranteeUserID, e.GranteeGroupID)
case events.SpaceUnshared:
executant = e.Executant
users, err = ul.resolveID(ul.impersonate(e.Executant), e.GranteeUserID, e.GranteeGroupID)
case events.SpaceMembershipExpired:
users, err = ul.resolveID(ul.impersonate(e.SpaceOwner), e.GranteeUserID, e.GranteeGroupID)
// share related
case events.ShareCreated:
executant = e.Executant
users, err = ul.resolveID(ul.impersonate(e.Executant), e.GranteeUserID, e.GranteeGroupID)
case events.ShareRemoved:
executant = e.Executant
users, err = ul.resolveID(ul.impersonate(e.Executant), e.GranteeUserID, e.GranteeGroupID)
case events.ShareExpired:
users, err = ul.resolveID(ul.impersonate(e.ShareOwner), e.GranteeUserID, e.GranteeGroupID)
@@ -122,6 +129,8 @@ func (ul *UserlogService) MemorizeEvents(ch <-chan events.Event) {
// II) filter users who want to receive the event
// This step is postponed for later.
// For now each user should get all events she is eligible to receive
// ...except notifications for their own actions
users = removeExecutant(users, executant)
// III) store the eventID for each user
for _, id := range users {
@@ -451,6 +460,16 @@ func listStorageSpaceRequest(spaceID string) *storageprovider.ListStorageSpacesR
}
}
func removeExecutant(users []string, executant *user.UserId) []string {
var usrs []string
for _, u := range users {
if u != executant.GetOpaqueId() {
usrs = append(usrs, u)
}
}
return usrs
}
type permissionChecker func(*storageprovider.ResourcePermissions) bool
func viewer(perms *storageprovider.ResourcePermissions) bool {

View File

@@ -73,9 +73,9 @@ var _ = Describe("UserlogService", func() {
It("it stores, returns and deletes a couple of events", func() {
ids := make(map[string]struct{})
ids[bus.Publish(events.SpaceDisabled{Executant: &user.UserId{OpaqueId: "userid"}})] = struct{}{}
ids[bus.Publish(events.SpaceDisabled{Executant: &user.UserId{OpaqueId: "userid"}})] = struct{}{}
ids[bus.Publish(events.SpaceDisabled{Executant: &user.UserId{OpaqueId: "userid"}})] = struct{}{}
ids[bus.Publish(events.SpaceDisabled{Executant: &user.UserId{OpaqueId: "executinguserid"}})] = struct{}{}
ids[bus.Publish(events.SpaceDisabled{Executant: &user.UserId{OpaqueId: "executinguserid"}})] = struct{}{}
ids[bus.Publish(events.SpaceDisabled{Executant: &user.UserId{OpaqueId: "executinguserid"}})] = struct{}{}
// ids[bus.Publish(events.SpaceMembershipExpired{SpaceOwner: &user.UserId{OpaqueId: "userid"}})] = struct{}{}
// ids[bus.Publish(events.ShareCreated{Executant: &user.UserId{OpaqueId: "userid"}})] = struct{}{}