Skip to content

Commit

Permalink
fixed timestamp bug
Browse files Browse the repository at this point in the history
  • Loading branch information
padaliyajay committed Dec 24, 2024
1 parent 640c9e3 commit f28af79
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
13 changes: 6 additions & 7 deletions hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,23 @@ import (
"fmt"
"net/http"
"net/url"
"strconv"
)

type HookEvent struct {
Id string
Url string
Payload string
Timestamp uint64
Timestamp string
Secret string
}

func (h *HookEvent) Process() error {
data := url.Values{}
data.Set("payload", h.Payload)
data.Set("timestamp", strconv.FormatUint(h.Timestamp, 10))
data.Set("secret", h.Secret)
postData := url.Values{}
postData.Set("payload", h.Payload)
postData.Set("timestamp", h.Timestamp)
postData.Set("secret", h.Secret)

resp, err := http.PostForm(h.Url, data)
resp, err := http.PostForm(h.Url, postData)

if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (b *RedisBroker) getHook(id string) (*HookEvent, error) {
hook.Payload = result[1].(string)
}
if result[2] != nil { // timestamp
hook.Timestamp = result[2].(uint64)
hook.Timestamp = result[2].(string)
}
if result[3] != nil { // secret
hook.Secret = result[3].(string)
Expand All @@ -53,7 +53,7 @@ func (b *RedisBroker) Run(manager *HookManager) {
case <-b.ctx.Done():
return
default:
result, _ := b.client.BZPopMin(b.ctx, time.Minute, "asynchooks:"+manager.Channel).Result()
result, _ := b.client.BZPopMin(b.ctx, time.Second*10, "asynchooks:"+manager.Channel).Result()

if result != nil {
id := result.Member.(string)
Expand Down

0 comments on commit f28af79

Please sign in to comment.