mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-29 22:36:14 -06:00
change the way dry works, slightly
This commit is contained in:
parent
ce4d14a688
commit
af14acb266
1 changed files with 14 additions and 18 deletions
|
|
@ -345,6 +345,10 @@ func (s *Subscriptions) ProcessDomainPermissionSubscription(
|
||||||
// processDomainPermission processes one wanted domain
|
// processDomainPermission processes one wanted domain
|
||||||
// permission discovered via a domain permission sub's URI.
|
// permission discovered via a domain permission sub's URI.
|
||||||
//
|
//
|
||||||
|
// If dry == true, then the returned boolean indicates whether
|
||||||
|
// the permission would actually be created. If dry == false,
|
||||||
|
// the bool indicates whether the permission was created or adopted.
|
||||||
|
//
|
||||||
// Error will only be returned in case of an actual database
|
// Error will only be returned in case of an actual database
|
||||||
// error, else the error will be logged and nil returned.
|
// error, else the error will be logged and nil returned.
|
||||||
func (s *Subscriptions) processDomainPermission(
|
func (s *Subscriptions) processDomainPermission(
|
||||||
|
|
@ -355,22 +359,18 @@ func (s *Subscriptions) processDomainPermission(
|
||||||
higherPrios []*gtsmodel.DomainPermissionSubscription,
|
higherPrios []*gtsmodel.DomainPermissionSubscription,
|
||||||
dry bool,
|
dry bool,
|
||||||
) (bool, error) {
|
) (bool, error) {
|
||||||
// Set to true if domain permission
|
|
||||||
// actually (would be) created.
|
|
||||||
var created bool
|
|
||||||
|
|
||||||
// If domain is excluded from automatic
|
// If domain is excluded from automatic
|
||||||
// permission creation, don't process it.
|
// permission creation, don't process it.
|
||||||
domain := wantedPerm.GetDomain()
|
domain := wantedPerm.GetDomain()
|
||||||
excluded, err := s.state.DB.IsDomainPermissionExcluded(ctx, domain)
|
excluded, err := s.state.DB.IsDomainPermissionExcluded(ctx, domain)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Proper db error.
|
// Proper db error.
|
||||||
return created, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if excluded {
|
if excluded {
|
||||||
l.Debug("domain is excluded, skipping")
|
l.Debug("domain is excluded, skipping")
|
||||||
return created, nil
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if a permission already exists for
|
// Check if a permission already exists for
|
||||||
|
|
@ -381,22 +381,19 @@ func (s *Subscriptions) processDomainPermission(
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Proper db error.
|
// Proper db error.
|
||||||
return created, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if covered {
|
if covered {
|
||||||
l.Debug("domain is covered by a higher-priority subscription, skipping")
|
l.Debug("domain is covered by a higher-priority subscription, skipping")
|
||||||
return created, nil
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// At this point we know we
|
|
||||||
// should create the perm.
|
|
||||||
created = true
|
|
||||||
|
|
||||||
if dry {
|
if dry {
|
||||||
// Don't do creation or side
|
// If this is a dry run, return
|
||||||
// effects if we're dry running.
|
// now without doing any DB changes.
|
||||||
return created, nil
|
wouldBeCreated := !covered && existingPerm == nil
|
||||||
|
return wouldBeCreated, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle perm creation differently depending
|
// Handle perm creation differently depending
|
||||||
|
|
@ -512,11 +509,10 @@ func (s *Subscriptions) processDomainPermission(
|
||||||
|
|
||||||
if err != nil && !errors.Is(err, db.ErrAlreadyExists) {
|
if err != nil && !errors.Is(err, db.ErrAlreadyExists) {
|
||||||
// Proper db error.
|
// Proper db error.
|
||||||
return created, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
created = true
|
return true, nil
|
||||||
return created, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func permsFromCSV(
|
func permsFromCSV(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue