Convert bool string comparisons to strconv.ParseBool for REST parameters (#13650)
* Convert bool string comparisons to strconv.ParseBool for REST parameters * Log failed bool conversions * Rename errors, changed log levels * drop strconv.ParseBool error handling If the query string parameter is omitted, strconv.ParseBool returns an error for the empty strings, which spams the logs. Instead, just assume the default semantics of a `false` return value if an error occurs. * allow randomized Client4 booleans It's hard to test api4's handling of the various boolean input values accepted. Extend Client4 with support for overriding how it builds those strings, and pick a random value on test startup. * gofmt -s Co-authored-by: mattermod <mattermod@users.noreply.github.com> Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com> Co-authored-by: Jesse Hallam <jesse.hallam@gmail.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
f7a91c7cf9
Коммит
2135096d88
@@ -213,10 +213,7 @@ func deleteCommand(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func listCommands(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
customOnly, failConv := strconv.ParseBool(r.URL.Query().Get("custom_only"))
|
||||
if failConv != nil {
|
||||
customOnly = false
|
||||
}
|
||||
customOnly, _ := strconv.ParseBool(r.URL.Query().Get("custom_only"))
|
||||
|
||||
teamId := r.URL.Query().Get("team_id")
|
||||
if len(teamId) == 0 {
|
||||
|
||||
Ссылка в новой задаче
Block a user