mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-01-10 16:28:13 +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.
|
// Get a transport for calling permSub.URI.
|
||||||
tsport, err := p.transport.NewTransportForUsername(ctx, acct.Username)
|
tsport, err := p.transport.NewTransportForUsername(ctx, acct.Username)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -334,6 +329,10 @@ func(ps *gtsmodel.DomainPermissionSubscription) bool {
|
|||||||
return nil, gtserror.NewErrorInternalError(err)
|
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.
|
// Call the permSub.URI and parse a list of perms from it.
|
||||||
// Any error returned here is a "real" one, not an error
|
// Any error returned here is a "real" one, not an error
|
||||||
// from fetching / parsing the list.
|
// from fetching / parsing the list.
|
||||||
@ -341,7 +340,7 @@ func(ps *gtsmodel.DomainPermissionSubscription) bool {
|
|||||||
ctx,
|
ctx,
|
||||||
permSub,
|
permSub,
|
||||||
tsport,
|
tsport,
|
||||||
getHigherPrios,
|
higherPrios,
|
||||||
true, // Dry run.
|
true, // Dry run.
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -168,15 +168,13 @@ func (s *Subscriptions) ProcessDomainPermissionSubscriptions(
|
|||||||
for i, permSub := range permSubs {
|
for i, permSub := range permSubs {
|
||||||
// Higher priority permission subs = everything
|
// Higher priority permission subs = everything
|
||||||
// above this permission sub in the slice.
|
// above this permission sub in the slice.
|
||||||
getHigherPrios := func() ([]*gtsmodel.DomainPermissionSubscription, error) {
|
higherPrios := permSubs[:i]
|
||||||
return permSubs[:i], nil
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err := s.ProcessDomainPermissionSubscription(
|
_, err := s.ProcessDomainPermissionSubscription(
|
||||||
ctx,
|
ctx,
|
||||||
permSub,
|
permSub,
|
||||||
tsport,
|
tsport,
|
||||||
getHigherPrios,
|
higherPrios,
|
||||||
false, // Not dry. Wet, if you will.
|
false, // Not dry. Wet, if you will.
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -221,7 +219,7 @@ func (s *Subscriptions) ProcessDomainPermissionSubscription(
|
|||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
permSub *gtsmodel.DomainPermissionSubscription,
|
permSub *gtsmodel.DomainPermissionSubscription,
|
||||||
tsport transport.Transport,
|
tsport transport.Transport,
|
||||||
getHigherPrios func() ([]*gtsmodel.DomainPermissionSubscription, error),
|
higherPrios []*gtsmodel.DomainPermissionSubscription,
|
||||||
dry bool,
|
dry bool,
|
||||||
) ([]gtsmodel.DomainPermission, error) {
|
) ([]gtsmodel.DomainPermission, error) {
|
||||||
l := log.
|
l := log.
|
||||||
@ -311,14 +309,6 @@ func (s *Subscriptions) ProcessDomainPermissionSubscription(
|
|||||||
permSub.ETag = resp.ETag
|
permSub.ETag = resp.ETag
|
||||||
permSub.Error = ""
|
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
|
// Keep track of which domain perms are
|
||||||
// created (or would be, if dry == true).
|
// created (or would be, if dry == true).
|
||||||
createdPerms := make([]gtsmodel.DomainPermission, 0, len(wantedPerms))
|
createdPerms := make([]gtsmodel.DomainPermission, 0, len(wantedPerms))
|
||||||
|
Loading…
Reference in New Issue
Block a user