Skip to content

Commit 4ec8551

Browse files
authored
fix webhook bug of response info is not displayed in UI (#4000)
1 parent a2f0c57 commit 4ec8551

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

models/webhook.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,14 @@ func (t *HookTask) AfterLoad() {
494494

495495
t.RequestInfo = &HookRequest{}
496496
if err := json.Unmarshal([]byte(t.RequestContent), t.RequestInfo); err != nil {
497-
log.Error(3, "Unmarshal[%d]: %v", t.ID, err)
497+
log.Error(3, "Unmarshal RequestContent[%d]: %v", t.ID, err)
498+
}
499+
500+
if len(t.ResponseContent) > 0 {
501+
t.ResponseInfo = &HookResponse{}
502+
if err := json.Unmarshal([]byte(t.ResponseContent), t.ResponseInfo); err != nil {
503+
log.Error(3, "Unmarshal ResponseContent[%d]: %v", t.ID, err)
504+
}
498505
}
499506
}
500507

@@ -665,6 +672,10 @@ func (t *HookTask) deliver() {
665672
log.Trace("Hook delivery failed: %s", t.UUID)
666673
}
667674

675+
if err := UpdateHookTask(t); err != nil {
676+
log.Error(4, "UpdateHookTask [%d]: %v", t.ID, err)
677+
}
678+
668679
// Update webhook last delivery status.
669680
w, err := GetWebhookByID(t.HookID)
670681
if err != nil {
@@ -717,10 +728,6 @@ func DeliverHooks() {
717728
// Update hook task status.
718729
for _, t := range tasks {
719730
t.deliver()
720-
721-
if err := UpdateHookTask(t); err != nil {
722-
log.Error(4, "UpdateHookTask [%d]: %v", t.ID, err)
723-
}
724731
}
725732

726733
// Start listening on new hook requests.
@@ -741,10 +748,6 @@ func DeliverHooks() {
741748
}
742749
for _, t := range tasks {
743750
t.deliver()
744-
if err := UpdateHookTask(t); err != nil {
745-
log.Error(4, "UpdateHookTask [%d]: %v", t.ID, err)
746-
continue
747-
}
748751
}
749752
}
750753
}

0 commit comments

Comments
 (0)