diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2018-05-23 14:12:02 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-23 14:12:02 +0800 |
commit | 4ec8551490688a887a526f24ba287d30fa409811 (patch) | |
tree | 7a5d84b7749a5e0dd2b604da83678095691ff01b /models/webhook.go | |
parent | a2f0c575845c1c78401fc8fed8d7b98381d2c491 (diff) | |
download | gitea-4ec8551490688a887a526f24ba287d30fa409811.tar.gz gitea-4ec8551490688a887a526f24ba287d30fa409811.zip |
fix webhook bug of response info is not displayed in UI (#4000)
Diffstat (limited to 'models/webhook.go')
-rw-r--r-- | models/webhook.go | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/models/webhook.go b/models/webhook.go index c44ca2960d..77662f5275 100644 --- a/models/webhook.go +++ b/models/webhook.go @@ -494,7 +494,14 @@ func (t *HookTask) AfterLoad() { t.RequestInfo = &HookRequest{} if err := json.Unmarshal([]byte(t.RequestContent), t.RequestInfo); err != nil { - log.Error(3, "Unmarshal[%d]: %v", t.ID, err) + log.Error(3, "Unmarshal RequestContent[%d]: %v", t.ID, err) + } + + if len(t.ResponseContent) > 0 { + t.ResponseInfo = &HookResponse{} + if err := json.Unmarshal([]byte(t.ResponseContent), t.ResponseInfo); err != nil { + log.Error(3, "Unmarshal ResponseContent[%d]: %v", t.ID, err) + } } } @@ -665,6 +672,10 @@ func (t *HookTask) deliver() { log.Trace("Hook delivery failed: %s", t.UUID) } + if err := UpdateHookTask(t); err != nil { + log.Error(4, "UpdateHookTask [%d]: %v", t.ID, err) + } + // Update webhook last delivery status. w, err := GetWebhookByID(t.HookID) if err != nil { @@ -717,10 +728,6 @@ func DeliverHooks() { // Update hook task status. for _, t := range tasks { t.deliver() - - if err := UpdateHookTask(t); err != nil { - log.Error(4, "UpdateHookTask [%d]: %v", t.ID, err) - } } // Start listening on new hook requests. @@ -741,10 +748,6 @@ func DeliverHooks() { } for _, t := range tasks { t.deliver() - if err := UpdateHookTask(t); err != nil { - log.Error(4, "UpdateHookTask [%d]: %v", t.ID, err) - continue - } } } } |