mirror of
https://github.com/go-gitea/gitea
synced 2024-11-16 06:51:29 +01:00
#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.
This commit is contained in:
parent
8bf3032b16
commit
297e772c20
6 changed files with 11 additions and 8 deletions
|
@ -13,7 +13,7 @@ watch_dirs = [
|
||||||
watch_exts = [".go"]
|
watch_exts = [".go"]
|
||||||
build_delay = 1500
|
build_delay = 1500
|
||||||
cmds = [
|
cmds = [
|
||||||
["go", "install", "-v", "-race"], # sqlite redis memcache cert pam tidb
|
["go", "install", "-v", "-race"], # sqlite cert pam tidb
|
||||||
["go", "build", "-race"],
|
["go", "build", "-race"],
|
||||||
["./gogs", "web"]
|
["./gogs", "web"]
|
||||||
]
|
]
|
|
@ -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)
|
![](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 |
|
| Web | UI | Preview |
|
||||||
|:-------------:|:-------:|:-------:|
|
|:-------------:|:-------:|:-------:|
|
||||||
|
|
2
gogs.go
2
gogs.go
|
@ -17,7 +17,7 @@ import (
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
const APP_VER = "0.8.32.0207"
|
const APP_VER = "0.8.33.0210"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
|
|
|
@ -398,6 +398,7 @@ func PrepareWebhooks(repo *Repository, event HookEventType, p api.Payloader) err
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var payloader api.Payloader
|
||||||
for _, w := range ws {
|
for _, w := range ws {
|
||||||
switch event {
|
switch event {
|
||||||
case HOOK_EVENT_CREATE:
|
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 {
|
switch w.HookTaskType {
|
||||||
case SLACK:
|
case SLACK:
|
||||||
p, err = GetSlackPayload(p, event, w.Meta)
|
payloader, err = GetSlackPayload(p, event, w.Meta)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("GetSlackPayload: %v", err)
|
return fmt.Errorf("GetSlackPayload: %v", err)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
p.SetSecret(w.Secret)
|
p.SetSecret(w.Secret)
|
||||||
|
payloader = p
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = CreateHookTask(&HookTask{
|
if err = CreateHookTask(&HookTask{
|
||||||
|
@ -425,7 +428,7 @@ func PrepareWebhooks(repo *Repository, event HookEventType, p api.Payloader) err
|
||||||
HookID: w.ID,
|
HookID: w.ID,
|
||||||
Type: w.HookTaskType,
|
Type: w.HookTaskType,
|
||||||
URL: w.URL,
|
URL: w.URL,
|
||||||
Payloader: p,
|
Payloader: payloader,
|
||||||
ContentType: w.ContentType,
|
ContentType: w.ContentType,
|
||||||
EventType: HOOK_EVENT_PUSH,
|
EventType: HOOK_EVENT_PUSH,
|
||||||
IsSSL: w.IsSSL,
|
IsSSL: w.IsSSL,
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
||||||
0.8.32.0207
|
0.8.33.0210
|
Loading…
Reference in a new issue