From f28af79149fc9aa71b1b42c1794197968bc3cbd1 Mon Sep 17 00:00:00 2001 From: padaliyajay Date: Tue, 24 Dec 2024 14:05:00 +0530 Subject: [PATCH] fixed timestamp bug --- hook.go | 13 ++++++------- redis.go | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/hook.go b/hook.go index 43ec474..6517415 100644 --- a/hook.go +++ b/hook.go @@ -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 diff --git a/redis.go b/redis.go index 6f9e9e5..4d32688 100644 --- a/redis.go +++ b/redis.go @@ -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) @@ -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)