mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-04-12 04:14:08 +00:00
use switch for permType instead of if/else
This commit is contained in:
parent
52c3847dc0
commit
00038c471f
1 changed files with 15 additions and 9 deletions
|
@ -600,9 +600,10 @@ func permsFromCSV(
|
|||
// Instantiate the permission
|
||||
// as either block or allow.
|
||||
var perm gtsmodel.DomainPermission
|
||||
if permType == gtsmodel.DomainPermissionBlock {
|
||||
switch permType {
|
||||
case gtsmodel.DomainPermissionBlock:
|
||||
perm = >smodel.DomainBlock{Domain: domain}
|
||||
} else {
|
||||
case gtsmodel.DomainPermissionAllow:
|
||||
perm = >smodel.DomainAllow{Domain: domain}
|
||||
}
|
||||
|
||||
|
@ -660,9 +661,10 @@ func permsFromJSON(
|
|||
// Instantiate the permission
|
||||
// as either block or allow.
|
||||
var perm gtsmodel.DomainPermission
|
||||
if permType == gtsmodel.DomainPermissionBlock {
|
||||
switch permType {
|
||||
case gtsmodel.DomainPermissionBlock:
|
||||
perm = >smodel.DomainBlock{Domain: domain}
|
||||
} else {
|
||||
case gtsmodel.DomainPermissionAllow:
|
||||
perm = >smodel.DomainAllow{Domain: domain}
|
||||
}
|
||||
|
||||
|
@ -711,9 +713,10 @@ func permsFromPlain(
|
|||
// Instantiate the permission
|
||||
// as either block or allow.
|
||||
var perm gtsmodel.DomainPermission
|
||||
if permType == gtsmodel.DomainPermissionBlock {
|
||||
switch permType {
|
||||
case gtsmodel.DomainPermissionBlock:
|
||||
perm = >smodel.DomainBlock{Domain: domain}
|
||||
} else {
|
||||
case gtsmodel.DomainPermissionAllow:
|
||||
perm = >smodel.DomainAllow{Domain: domain}
|
||||
}
|
||||
|
||||
|
@ -758,13 +761,16 @@ func (s *Subscriptions) existingCovered(
|
|||
covered bool,
|
||||
err error,
|
||||
) {
|
||||
// Check for existing permission of appropriate type.
|
||||
// Check for existing perm
|
||||
// of appropriate type.
|
||||
var dbErr error
|
||||
if permType == gtsmodel.DomainPermissionBlock {
|
||||
switch permType {
|
||||
case gtsmodel.DomainPermissionBlock:
|
||||
existingPerm, dbErr = s.state.DB.GetDomainBlock(ctx, domain)
|
||||
} else {
|
||||
case gtsmodel.DomainPermissionAllow:
|
||||
existingPerm, dbErr = s.state.DB.GetDomainAllow(ctx, domain)
|
||||
}
|
||||
|
||||
if dbErr != nil && !errors.Is(dbErr, db.ErrNoEntries) {
|
||||
// Real db error.
|
||||
err = dbErr
|
||||
|
|
Loading…
Reference in a new issue