From c81b26b0e52f55fcdf94b50a14bca3dfc375e2a9 Mon Sep 17 00:00:00 2001 From: oliverpool <3864879+oliverpool@users.noreply.github.com> Date: Thu, 11 Aug 2022 17:48:23 +0200 Subject: refactor webhook *NewPost (#20729) * refactor webhook *NewPost * remove empty values * always show errs.Message * remove utils.IsValidSlackChannel * move IsValidSlackChannel to services/webhook package * binding: handle empty Message case * make IsValidSlackChannel more strict --- modules/web/middleware/binding.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/web/middleware/binding.go b/modules/web/middleware/binding.go index 88a3920f6e..636e655b9e 100644 --- a/modules/web/middleware/binding.go +++ b/modules/web/middleware/binding.go @@ -136,7 +136,16 @@ func Validate(errs binding.Errors, data map[string]interface{}, f Form, l transl case validation.ErrRegexPattern: data["ErrorMsg"] = trName + l.Tr("form.regex_pattern_error", errs[0].Message) default: - data["ErrorMsg"] = l.Tr("form.unknown_error") + " " + errs[0].Classification + msg := errs[0].Classification + if msg != "" && errs[0].Message != "" { + msg += ": " + } + + msg += errs[0].Message + if msg == "" { + msg = l.Tr("form.unknown_error") + } + data["ErrorMsg"] = trName + ": " + msg } return errs } -- cgit v1.2.3