Skip to content

Commit f368790

Browse files
authored
Fixed webhook payload bug (#116)
1 parent a75e78d commit f368790

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

worker/producer.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package worker
22

33
import (
44
"context"
5+
"encoding/json"
56
"time"
67

78
"github.com/frain-dev/convoy"
@@ -64,7 +65,12 @@ func (p *Producer) postMessages(msgRepo convoy.MessageRepository, m convoy.Messa
6465
continue
6566
}
6667

67-
bStr := string(m.Data)
68+
bytes, err := json.Marshal(m.Data)
69+
if err != nil {
70+
log.Errorf("error occurred while parsing json")
71+
}
72+
73+
bStr := string(bytes)
6874
hmac, err := util.ComputeJSONHmac(p.signatureConfig.Hash, bStr, secret, false)
6975
if err != nil {
7076
log.Errorf("error occurred while generating hmac signature - %+v\n", err)
@@ -74,7 +80,7 @@ func (p *Producer) postMessages(msgRepo convoy.MessageRepository, m convoy.Messa
7480
attemptStatus := convoy.FailureMessageStatus
7581
start := time.Now()
7682

77-
resp, err := p.dispatch.SendRequest(e.TargetURL, string(convoy.HttpPost), []byte(bStr), string(p.signatureConfig.Header), hmac)
83+
resp, err := p.dispatch.SendRequest(e.TargetURL, string(convoy.HttpPost), bytes, string(p.signatureConfig.Header), hmac)
7884
status := "-"
7985
statusCode := 0
8086
if resp != nil {

0 commit comments

Comments
 (0)