aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/auth/repo_form.go24
-rw-r--r--modules/middleware/context.go42
-rw-r--r--modules/setting/setting.go2
3 files changed, 36 insertions, 32 deletions
diff --git a/modules/auth/repo_form.go b/modules/auth/repo_form.go
index cbabbb4668..a0700e821a 100644
--- a/modules/auth/repo_form.go
+++ b/modules/auth/repo_form.go
@@ -65,13 +65,17 @@ func (f *RepoSettingForm) Validate(ctx *macaron.Context, errs binding.Errors) bi
// \__/\ / \___ >___ /___| /___| /\____/|__|_ \
// \/ \/ \/ \/ \/ \/
+type WebhookForm struct {
+ HookType string `binding:"Required"`
+ PushOnly bool
+ Active bool
+}
+
type NewWebhookForm struct {
- HookTaskType string `form:"hook_type" binding:"Required"`
- PayloadUrl string `form:"payload_url" binding:"Required;Url"`
- ContentType string `form:"content_type" binding:"Required"`
- Secret string `form:"secret"`
- PushOnly bool `form:"push_only"`
- Active bool `form:"active"`
+ PayloadURL string `binding:"Required;Url"`
+ ContentType int `binding:"Required"`
+ Secret string
+ WebhookForm
}
func (f *NewWebhookForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
@@ -79,11 +83,9 @@ func (f *NewWebhookForm) Validate(ctx *macaron.Context, errs binding.Errors) bin
}
type NewSlackHookForm struct {
- HookTaskType string `form:"hook_type" binding:"Required"`
- PayloadUrl string `form:"payload_url" binding:"Required`
- Channel string `form:"channel" binding:"Required"`
- PushOnly bool `form:"push_only"`
- Active bool `form:"active"`
+ PayloadURL string `binding:"Required`
+ Channel string `binding:"Required"`
+ WebhookForm
}
func (f *NewSlackHookForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
diff --git a/modules/middleware/context.go b/modules/middleware/context.go
index 8a8867da4d..b25674f60f 100644
--- a/modules/middleware/context.go
+++ b/modules/middleware/context.go
@@ -26,6 +26,27 @@ import (
"github.com/gogits/gogs/modules/setting"
)
+type RepoContext struct {
+ AccessMode models.AccessMode
+ IsWatching bool
+ IsBranch bool
+ IsTag bool
+ IsCommit bool
+ Repository *models.Repository
+ Owner *models.User
+ Commit *git.Commit
+ Tag *git.Tag
+ GitRepo *git.Repository
+ BranchName string
+ TagName string
+ TreeName string
+ CommitId string
+ RepoLink string
+ CloneLink models.CloneLink
+ CommitsCount int
+ Mirror *models.Mirror
+}
+
// Context represents context of a request.
type Context struct {
*macaron.Context
@@ -51,27 +72,6 @@ type Context struct {
}
}
-type RepoContext struct {
- AccessMode models.AccessMode
- IsWatching bool
- IsBranch bool
- IsTag bool
- IsCommit bool
- Repository *models.Repository
- Owner *models.User
- Commit *git.Commit
- Tag *git.Tag
- GitRepo *git.Repository
- BranchName string
- TagName string
- TreeName string
- CommitId string
- RepoLink string
- CloneLink models.CloneLink
- CommitsCount int
- Mirror *models.Mirror
-}
-
// IsOwner returns true if current user is the owner of repository.
func (r RepoContext) IsOwner() bool {
return r.AccessMode >= models.ACCESS_MODE_OWNER
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index bb78201500..f008f81a07 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -81,6 +81,7 @@ var (
QueueLength int
DeliverTimeout int
SkipTLSVerify bool
+ Types []string
}
// Repository settings.
@@ -599,6 +600,7 @@ func newWebhookService() {
Webhook.QueueLength = sec.Key("QUEUE_LENGTH").MustInt(1000)
Webhook.DeliverTimeout = sec.Key("DELIVER_TIMEOUT").MustInt(5)
Webhook.SkipTLSVerify = sec.Key("SKIP_TLS_VERIFY").MustBool()
+ Webhook.Types = []string{"gogs", "slack"}
}
func NewServices() {