Browse Source

#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.
pull/2603/head
Unknwon 9 years ago
parent
commit
297e772c20
  1. 2
      .bra.toml
  2. 2
      README.md
  3. 2
      gogs.go
  4. 7
      models/webhook.go
  5. 4
      modules/bindata/bindata.go
  6. 2
      templates/.VERSION

2
.bra.toml

@ -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"]
] ]

2
README.md

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

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

7
models/webhook.go

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

4
modules/bindata/bindata.go

File diff suppressed because one or more lines are too long

2
templates/.VERSION

@ -1 +1 @@
0.8.32.0207 0.8.33.0210
Loading…
Cancel
Save