#2485 fix payloads mixed up for webhook

When repository contains a Slack type hook,
it changes original payload content.

This patch fixes it by using a local object to store
newly created Slack payload instead of assigning
back to the same variable.
release/v1.15
Unknwon 2016-02-10 15:21:39 -05:00
parent 8bf3032b16
commit 297e772c20
6 changed files with 11 additions and 8 deletions

View File

@ -13,7 +13,7 @@ watch_dirs = [
watch_exts = [".go"]
build_delay = 1500
cmds = [
["go", "install", "-v", "-race"], # sqlite redis memcache cert pam tidb
["go", "install", "-v", "-race"], # sqlite cert pam tidb
["go", "build", "-race"],
["./gogs", "web"]
]

View File

@ -3,7 +3,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra
![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)
##### Current version: 0.8.32
##### Current version: 0.8.33
| Web | UI | Preview |
|:-------------:|:-------:|:-------:|

View File

@ -17,7 +17,7 @@ import (
"github.com/gogits/gogs/modules/setting"
)
const APP_VER = "0.8.32.0207"
const APP_VER = "0.8.33.0210"
func init() {
runtime.GOMAXPROCS(runtime.NumCPU())

View File

@ -398,6 +398,7 @@ func PrepareWebhooks(repo *Repository, event HookEventType, p api.Payloader) err
return nil
}
var payloader api.Payloader
for _, w := range ws {
switch event {
case HOOK_EVENT_CREATE:
@ -410,14 +411,16 @@ func PrepareWebhooks(repo *Repository, event HookEventType, p api.Payloader) err
}
}
// Use separate objects so modifcations won't be made on payload on non-Gogs type hooks.
switch w.HookTaskType {
case SLACK:
p, err = GetSlackPayload(p, event, w.Meta)
payloader, err = GetSlackPayload(p, event, w.Meta)
if err != nil {
return fmt.Errorf("GetSlackPayload: %v", err)
}
default:
p.SetSecret(w.Secret)
payloader = p
}
if err = CreateHookTask(&HookTask{
@ -425,7 +428,7 @@ func PrepareWebhooks(repo *Repository, event HookEventType, p api.Payloader) err
HookID: w.ID,
Type: w.HookTaskType,
URL: w.URL,
Payloader: p,
Payloader: payloader,
ContentType: w.ContentType,
EventType: HOOK_EVENT_PUSH,
IsSSL: w.IsSSL,

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
0.8.32.0207
0.8.33.0210