From 82f7a01ded7e83d238d687831bcd6ec415da31f5 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Wed, 18 Mar 2015 04:51:02 -0400 Subject: [PATCH] #1064: X-Gogs-Event header is empty --- gogs.go | 2 +- models/action.go | 40 ++++++++++++++++++---------------------- models/webhook.go | 2 +- templates/.VERSION | 2 +- 4 files changed, 21 insertions(+), 25 deletions(-) diff --git a/gogs.go b/gogs.go index cb2ad043d..95cd00453 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.5.16.0317 Beta" +const APP_VER = "0.5.16.0318 Beta" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/models/action.go b/models/action.go index 037ccbd61..d3393728f 100644 --- a/models/action.go +++ b/models/action.go @@ -417,32 +417,28 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string, continue } + var payload BasePayload switch w.HookTaskType { case SLACK: - { - s, err := GetSlackPayload(p, w.Meta) - if err != nil { - return errors.New("action.GetSlackPayload: " + err.Error()) - } - CreateHookTask(&HookTask{ - Type: w.HookTaskType, - Url: w.Url, - BasePayload: s, - ContentType: w.ContentType, - IsSsl: w.IsSsl, - }) + s, err := GetSlackPayload(p, w.Meta) + if err != nil { + return errors.New("action.GetSlackPayload: " + err.Error()) } + payload = s default: - { - p.Secret = w.Secret - CreateHookTask(&HookTask{ - Type: w.HookTaskType, - Url: w.Url, - BasePayload: p, - ContentType: w.ContentType, - IsSsl: w.IsSsl, - }) - } + payload = p + p.Secret = w.Secret + } + + if err = CreateHookTask(&HookTask{ + Type: w.HookTaskType, + Url: w.Url, + BasePayload: payload, + ContentType: w.ContentType, + EventType: HOOK_EVENT_PUSH, + IsSsl: w.IsSsl, + }); err != nil { + return fmt.Errorf("CreateHookTask: %v", err) } } diff --git a/models/webhook.go b/models/webhook.go index 96af0b696..bfa52b990 100644 --- a/models/webhook.go +++ b/models/webhook.go @@ -205,7 +205,7 @@ func IsValidHookTaskType(name string) bool { type HookEventType string const ( - PUSH HookEventType = "push" + HOOK_EVENT_PUSH HookEventType = "push" ) // FIXME: just use go-gogs-client structs maybe? diff --git a/templates/.VERSION b/templates/.VERSION index 8e8514e6d..4faf051b4 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.5.16.0317 Beta \ No newline at end of file +0.5.16.0318 Beta \ No newline at end of file