diff --git a/utils/user.go b/utils/user.go index 5f7f4e9..2b68ebe 100644 --- a/utils/user.go +++ b/utils/user.go @@ -23,19 +23,19 @@ func WildcardUserPatternsToRegexPatterns(wildCardPatterns []string) (*[]*regexp. // MatchUserWithAllowedRegexes tells if the given user id is allowed to use the bot, according to the given whitelist // An empty whitelist means "everyone is allowed" -func MatchUserWithAllowedRegexes(userID string, allowed []*regexp.Regexp) (bool, error) { +func MatchUserWithAllowedRegexes(userID string, allowed []*regexp.Regexp) bool { // No whitelisted users means everyone is whitelisted if len(allowed) == 0 { - return true, nil + return true } for _, regex := range allowed { if regex.MatchString(userID) { - return true, nil + return true } } - return false, nil + return false } // parseAllowedUserRule parses a user whitelisting rule and returns a regular expression which corresponds to it diff --git a/utils/user_test.go b/utils/user_test.go index 93d4329..ed6de85 100644 --- a/utils/user_test.go +++ b/utils/user_test.go @@ -202,10 +202,7 @@ func TestMatch(t *testing.T) { t.Error(err) } - actualResult, err := MatchUserWithAllowedRegexes(testData.checkedValue, *allowedUserRegexes) - if err != nil { - t.Error(err) - } + actualResult := MatchUserWithAllowedRegexes(testData.checkedValue, *allowedUserRegexes) if actualResult == testData.expectedResult { return