Slack webhook channel name cannot be empty or just contain an hashtag (#4786)

This commit is contained in:
Lanre Adelowo 2018-09-10 15:31:08 +01:00 committed by techknowlogick
parent 6e03390aa8
commit be48397945
6 changed files with 69 additions and 5 deletions

View file

@ -10,6 +10,8 @@ import (
"strings"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/routers/utils"
"github.com/Unknwon/com"
"github.com/go-macaron/binding"
"gopkg.in/macaron.v1"
@ -225,6 +227,11 @@ func (f *NewSlackHookForm) Validate(ctx *macaron.Context, errs binding.Errors) b
return validate(errs, ctx.Data, f, ctx.Locale)
}
// HasInvalidChannel validates the channel name is in the right format
func (f NewSlackHookForm) HasInvalidChannel() bool {
return !utils.IsValidSlackChannel(f.Channel)
}
// NewDiscordHookForm form for creating discord hook
type NewDiscordHookForm struct {
PayloadURL string `binding:"Required;ValidUrl"`