make higherPrios a simple slice

This commit is contained in:
tobi 2025-01-07 17:52:28 +01:00
commit 480ce48a3e
2 changed files with 8 additions and 19 deletions

View file

@ -168,15 +168,13 @@ func (s *Subscriptions) ProcessDomainPermissionSubscriptions(
for i, permSub := range permSubs {
// Higher priority permission subs = everything
// above this permission sub in the slice.
getHigherPrios := func() ([]*gtsmodel.DomainPermissionSubscription, error) {
return permSubs[:i], nil
}
higherPrios := permSubs[:i]
_, err := s.ProcessDomainPermissionSubscription(
ctx,
permSub,
tsport,
getHigherPrios,
higherPrios,
false, // Not dry. Wet, if you will.
)
if err != nil {
@ -221,7 +219,7 @@ func (s *Subscriptions) ProcessDomainPermissionSubscription(
ctx context.Context,
permSub *gtsmodel.DomainPermissionSubscription,
tsport transport.Transport,
getHigherPrios func() ([]*gtsmodel.DomainPermissionSubscription, error),
higherPrios []*gtsmodel.DomainPermissionSubscription,
dry bool,
) ([]gtsmodel.DomainPermission, error) {
l := log.
@ -311,14 +309,6 @@ func (s *Subscriptions) ProcessDomainPermissionSubscription(
permSub.ETag = resp.ETag
permSub.Error = ""
// Need a list of higher priority subscriptions
// to ensure we don't create permissions wrongly.
higherPrios, err := getHigherPrios()
if err != nil {
// Proper db error.
return nil, err
}
// Keep track of which domain perms are
// created (or would be, if dry == true).
createdPerms := make([]gtsmodel.DomainPermission, 0, len(wantedPerms))