diff --git a/store/tag.go b/store/tag.go index 1e926301f3bfa8e98b87f99bb01a63ecc0c59315..368bdd366bf496e8a894292a27b1433cb43b353c 100644 --- a/store/tag.go +++ b/store/tag.go @@ -21,6 +21,23 @@ const ( GenericType = "generic" ) +var ( + // AllowedTagTypes represent tag type strings that are allowed. + AllowedTagTypes = []string{ArtistType, CharacterType, CopyrightType, MetaType, GenericType} + allowedTagTypesMap = map[string]bool{ + ArtistType: true, + CharacterType: true, + CopyrightType: true, + MetaType: true, + GenericType: true, + } +) + +// TagTypeAllowed returns whether str is an allowed tag type. +func TagTypeAllowed(str string) bool { + return allowedTagTypesMap[str] +} + // Tag represents metadata of a tag. type Tag struct { Type string `json:"type"` @@ -131,13 +148,8 @@ func (s *Store) TagType(tag, t string) { return } - if t != ArtistType && - t != CharacterType && - t != CopyrightType && - t != GenericType && - t != MetaType { - log.Warnf("Invalid tag change on tag %s, got %s, expecting {%s,%s,%s,%s,%s}", tag, t, - ArtistType, CharacterType, CopyrightType, GenericType, MetaType) + if !TagTypeAllowed(t) { + log.Warnf("Invalid tag change on tag %s, got %s, expecting %s", tag, t, AllowedTagTypes) return } info := s.TagInfo(tag)