1
0
Fork 0
forked from forgejo/forgejo

#12, add/edit hook

This commit is contained in:
Unknwon 2014-11-13 12:57:00 -05:00
parent 9e22840483
commit 9dc3c93a6a
7 changed files with 192 additions and 24 deletions

View file

@ -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 (