mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	#12, add/edit hook
This commit is contained in:
		@@ -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 (
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user