mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-01-10 08:19:18 +01:00
make higherPrios a simple slice
This commit is contained in:
parent
7233c4d768
commit
480ce48a3e
@ -322,11 +322,6 @@ func(ps *gtsmodel.DomainPermissionSubscription) bool {
|
||||
},
|
||||
)
|
||||
|
||||
// Everything *before* the targeted subscription has a higher priority.
|
||||
getHigherPrios := func() ([]*gtsmodel.DomainPermissionSubscription, error) {
|
||||
return permSubs[:index], nil
|
||||
}
|
||||
|
||||
// Get a transport for calling permSub.URI.
|
||||
tsport, err := p.transport.NewTransportForUsername(ctx, acct.Username)
|
||||
if err != nil {
|
||||
@ -334,6 +329,10 @@ func(ps *gtsmodel.DomainPermissionSubscription) bool {
|
||||
return nil, gtserror.NewErrorInternalError(err)
|
||||
}
|
||||
|
||||
// Everything *before* the targeted
|
||||
// subscription has a higher priority.
|
||||
higherPrios := permSubs[:index]
|
||||
|
||||
// Call the permSub.URI and parse a list of perms from it.
|
||||
// Any error returned here is a "real" one, not an error
|
||||
// from fetching / parsing the list.
|
||||
@ -341,7 +340,7 @@ func(ps *gtsmodel.DomainPermissionSubscription) bool {
|
||||
ctx,
|
||||
permSub,
|
||||
tsport,
|
||||
getHigherPrios,
|
||||
higherPrios,
|
||||
true, // Dry run.
|
||||
)
|
||||
if err != nil {
|
||||
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user