[management] Emit activity events for batch group ops (#8180)

This commit is contained in:
Bethuel Mmbaga
2026-10-13 13:04:10 +03:00
committed by GitHub
parent 10e34090fa
commit 49ec0e2699
2 changed files with 42 additions and 7 deletions
+5 -5
View File
@@ -256,6 +256,7 @@ func (am *DefaultAccountManager) CreateGroups(ctx context.Context, accountID, us
for _, newGroup := range groups {
change := affectedpeers.Change{ChangedGroupIDs: []string{newGroup.ID}}
var snap *affectedpeers.Snapshot
var events []func()
err = am.Store.ExecuteInTransaction(ctx, func(transaction store.Store) error {
if err = validateNewGroup(ctx, transaction, accountID, newGroup); err != nil {
return err
@@ -263,6 +264,7 @@ func (am *DefaultAccountManager) CreateGroups(ctx context.Context, accountID, us
newGroup.AccountID = accountID
newGroup.PublicID = xid.New().String()
events = am.prepareGroupEvents(ctx, transaction, accountID, userID, newGroup)
if err = transaction.CreateGroup(ctx, newGroup); err != nil {
return err
@@ -273,9 +275,6 @@ func (am *DefaultAccountManager) CreateGroups(ctx context.Context, accountID, us
return err
}
events := am.prepareGroupEvents(ctx, transaction, accountID, userID, newGroup)
eventsToStore = append(eventsToStore, events...)
snap, err = affectedpeers.Load(ctx, transaction, accountID, change)
return err
})
@@ -290,6 +289,7 @@ func (am *DefaultAccountManager) CreateGroups(ctx context.Context, accountID, us
}
createdCount++
affected.add(snap.Expand(ctx, accountID, change))
eventsToStore = append(eventsToStore, events...)
}
for _, storeEvent := range eventsToStore {
@@ -358,6 +358,8 @@ func (am *DefaultAccountManager) updateSingleGroup(ctx context.Context, accountI
}
newGroup.PublicID = oldGroup.PublicID
events = am.prepareGroupEvents(ctx, transaction, accountID, userID, newGroup)
if err := transaction.UpdateGroup(ctx, newGroup); err != nil {
return err
}
@@ -372,8 +374,6 @@ func (am *DefaultAccountManager) updateSingleGroup(ctx context.Context, accountI
return err
}
events = am.prepareGroupEvents(ctx, transaction, accountID, userID, newGroup)
snap, err = affectedpeers.Load(ctx, transaction, accountID, change)
return err
})