diff options
author | Unknwon <u@gogs.io> | 2016-02-10 15:21:39 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-02-10 15:21:39 -0500 |
commit | 297e772c20382afa31ad30ab65827ce0aca58446 (patch) | |
tree | 58e9a28ecfcd0df94097cd06c6efc90c1ca440e3 /models/webhook.go | |
parent | 8bf3032b16039a0a87e02a842475a04846325258 (diff) | |
download | gitea-297e772c20382afa31ad30ab65827ce0aca58446.tar.gz gitea-297e772c20382afa31ad30ab65827ce0aca58446.zip |
#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.
Diffstat (limited to 'models/webhook.go')
-rw-r--r-- | models/webhook.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/models/webhook.go b/models/webhook.go index 27ac75fe07..bdfb62d899 100644 --- a/models/webhook.go +++ b/models/webhook.go @@ -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, |