Skip to content

Commit

Permalink
chore: switch to map[string]bool to simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
budak7273 committed Oct 20, 2023
1 parent dbfdd4f commit 357f674
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions gql/resolver_mods.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,13 @@ import (
"github.com/satisfactorymodding/smr-api/util/converter"
)

var DisallowedModReferences = map[string]struct{}{
"satisfactory": {},
"factorygame": {},
"sml": {},
"satisfactorymodloader": {},
"examplemod": {},
"docmod": {},
}

func ModReferenceBanned(modReference string) bool {
if _, found := DisallowedModReferences[strings.ToLower(modReference)]; found {
return true
}
return false
var DisallowedModReferences = map[string]bool{
"satisfactory": true,
"factorygame": true,
"sml": true,
"satisfactorymodloader": true,
"examplemod": true,
"docmod": true,
}

func (r *mutationResolver) CreateMod(ctx context.Context, mod generated.NewMod) (*generated.Mod, error) {
Expand All @@ -48,7 +41,7 @@ func (r *mutationResolver) CreateMod(ctx context.Context, mod generated.NewMod)
return nil, errors.Wrap(err, "validation failed")
}

if ModReferenceBanned(mod.ModReference) {
if DisallowedModReferences[strings.ToLower(mod.ModReference)] {
return nil, errors.New("using this mod reference is not allowed")
}

Expand Down

0 comments on commit 357f674

Please sign in to comment.