summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authoroliverpool <3864879+oliverpool@users.noreply.github.com>2022-08-11 17:48:23 +0200
committerGitHub <noreply@github.com>2022-08-11 17:48:23 +0200
commitc81b26b0e52f55fcdf94b50a14bca3dfc375e2a9 (patch)
treeacccd4400733b5505a86ca668ceb4167119789fe /modules
parent2b4d43dd4d7388ff73e99c143008ad4663142e61 (diff)
downloadgitea-c81b26b0e52f55fcdf94b50a14bca3dfc375e2a9.tar.gz
gitea-c81b26b0e52f55fcdf94b50a14bca3dfc375e2a9.zip
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
Diffstat (limited to 'modules')
-rw-r--r--modules/web/middleware/binding.go11
1 files changed, 10 insertions, 1 deletions
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
}