summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorUnknwon <joe2010xtmf@163.com>2014-11-13 12:57:00 -0500
committerUnknwon <joe2010xtmf@163.com>2014-11-13 12:57:00 -0500
commit9dc3c93a6a1f0d604aa5e4408a4c43c29b963b0c (patch)
tree0d2113af522fa36d2c73760c3aace4088ee3ae78 /models
parent9e2284048372864a7dbc5e192877ebdca04abcab (diff)
downloadgitea-9dc3c93a6a1f0d604aa5e4408a4c43c29b963b0c.tar.gz
gitea-9dc3c93a6a1f0d604aa5e4408a4c43c29b963b0c.zip
#12, add/edit hook
Diffstat (limited to 'models')
-rw-r--r--models/webhook.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/models/webhook.go b/models/webhook.go
index 3ee517cada..dbaac3e667 100644
--- a/models/webhook.go
+++ b/models/webhook.go
@@ -27,6 +27,16 @@ const (
FORM
)
+var hookContentTypes = map[string]HookContentType{
+ "json": JSON,
+ "form": FORM,
+}
+
+// ToHookContentType returns HookContentType by given name.
+func ToHookContentType(name string) HookContentType {
+ return hookContentTypes[name]
+}
+
func (t HookContentType) Name() string {
switch t {
case JSON:
@@ -37,6 +47,12 @@ func (t HookContentType) Name() string {
return ""
}
+// IsValidHookContentType returns true if given name is a valid hook content type.
+func IsValidHookContentType(name string) bool {
+ _, ok := hookContentTypes[name]
+ return ok
+}
+
// HookEvent represents events that will delivery hook.
type HookEvent struct {
PushOnly bool `json:"push_only"`
@@ -157,6 +173,16 @@ const (
SLACK
)
+var hookTaskTypes = map[string]HookTaskType{
+ "gogs": GOGS,
+ "slack": SLACK,
+}
+
+// ToHookTaskType returns HookTaskType by given name.
+func ToHookTaskType(name string) HookTaskType {
+ return hookTaskTypes[name]
+}
+
func (t HookTaskType) Name() string {
switch t {
case GOGS:
@@ -167,6 +193,12 @@ func (t HookTaskType) Name() string {
return ""
}
+// IsValidHookTaskType returns true if given name is a valid hook task type.
+func IsValidHookTaskType(name string) bool {
+ _, ok := hookTaskTypes[name]
+ return ok
+}
+
type HookEventType string
const (