From f57ac7a4c18feb5b69cb08a06fda88d2a45952ed Mon Sep 17 00:00:00 2001 From: elraphty Date: Wed, 6 Nov 2024 18:13:12 +0100 Subject: [PATCH 1/3] logged body data --- handlers/bounty.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/handlers/bounty.go b/handlers/bounty.go index 697150bc6..d4d269d79 100644 --- a/handlers/bounty.go +++ b/handlers/bounty.go @@ -625,6 +625,8 @@ func (h *bountyHandler) MakeBountyPayment(w http.ResponseWriter, r *http.Request bodyData := utils.BuildV2KeysendBodyData(amount, assignee.OwnerPubKey, assignee.OwnerRouteHint, memoText) jsonBody := []byte(bodyData) + fmt.Println("Payment Body Data", bodyData) + req, _ := http.NewRequest(http.MethodPost, url, bytes.NewBuffer(jsonBody)) req.Header.Set("x-admin-token", config.V2BotToken) req.Header.Set("Content-Type", "application/json") @@ -798,6 +800,8 @@ func (h *bountyHandler) MakeBountyPayment(w http.ResponseWriter, r *http.Request bodyData := utils.BuildKeysendBodyData(amount, assignee.OwnerPubKey, assignee.OwnerRouteHint, memoText) jsonBody := []byte(bodyData) + fmt.Println("Payment Body Data", bodyData) + req, _ := http.NewRequest(http.MethodPost, url, bytes.NewBuffer(jsonBody)) req.Header.Set("x-user-token", config.RelayAuthKey) req.Header.Set("Content-Type", "application/json") From a3f9975f948dfdf6770b3e84ab77a50413ebc684 Mon Sep 17 00:00:00 2001 From: elraphty Date: Wed, 6 Nov 2024 18:36:54 +0100 Subject: [PATCH 2/3] encoded bounty tilte --- handlers/bounty.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/handlers/bounty.go b/handlers/bounty.go index d4d269d79..43e38ed80 100644 --- a/handlers/bounty.go +++ b/handlers/bounty.go @@ -7,6 +7,7 @@ import ( "io" "log" "net/http" + "net/url" "strconv" "sync" "time" @@ -612,7 +613,8 @@ func (h *bountyHandler) MakeBountyPayment(w http.ResponseWriter, r *http.Request // Get Bounty Assignee assignee := h.db.GetPersonByPubkey(bounty.Assignee) - memoText := fmt.Sprintf("Payment For: %ss", bounty.Title) + memoData := fmt.Sprintf("Payment For: %ss", bounty.Title) + memoText := url.QueryEscape(memoData) now := time.Now() // If the v2contactkey is present @@ -625,7 +627,7 @@ func (h *bountyHandler) MakeBountyPayment(w http.ResponseWriter, r *http.Request bodyData := utils.BuildV2KeysendBodyData(amount, assignee.OwnerPubKey, assignee.OwnerRouteHint, memoText) jsonBody := []byte(bodyData) - fmt.Println("Payment Body Data", bodyData) + log.Println("Payment Body Data", bodyData) req, _ := http.NewRequest(http.MethodPost, url, bytes.NewBuffer(jsonBody)) req.Header.Set("x-admin-token", config.V2BotToken) @@ -800,7 +802,7 @@ func (h *bountyHandler) MakeBountyPayment(w http.ResponseWriter, r *http.Request bodyData := utils.BuildKeysendBodyData(amount, assignee.OwnerPubKey, assignee.OwnerRouteHint, memoText) jsonBody := []byte(bodyData) - fmt.Println("Payment Body Data", bodyData) + log.Println("Payment Body Data", bodyData) req, _ := http.NewRequest(http.MethodPost, url, bytes.NewBuffer(jsonBody)) req.Header.Set("x-user-token", config.RelayAuthKey) From 6a46544cfbe5693af302f5b475575f1e464e802f Mon Sep 17 00:00:00 2001 From: elraphty Date: Wed, 6 Nov 2024 18:54:39 +0100 Subject: [PATCH 3/3] added url encode to bounty test --- handlers/bounty_test.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/handlers/bounty_test.go b/handlers/bounty_test.go index d7ffb35d6..047295615 100644 --- a/handlers/bounty_test.go +++ b/handlers/bounty_test.go @@ -10,6 +10,7 @@ import ( "log" "net/http" "net/http/httptest" + "net/url" "os" "strconv" "strings" @@ -1418,7 +1419,8 @@ func TestMakeBountyPayment(t *testing.T) { bHandler2.getSocketConnections = mockGetSocketConnections bHandler2.userHasAccess = mockUserHasAccessTrue - memoText := fmt.Sprintf("Payment For: %ss", bounty.Title) + memoData := fmt.Sprintf("Payment For: %ss", bounty.Title) + memoText := url.QueryEscape(memoData) expectedUrl := fmt.Sprintf("%s/payment", config.RelayUrl) expectedBody := fmt.Sprintf(`{"amount": %d, "destination_key": "%s", "text": "memotext added for notification", "data": "%s"}`, bountyAmount, person.OwnerPubKey, memoText) @@ -1466,7 +1468,8 @@ func TestMakeBountyPayment(t *testing.T) { bHandler.getSocketConnections = mockGetSocketConnections bHandler.userHasAccess = mockUserHasAccessTrue - memoText := fmt.Sprintf("Payment For: %ss", bounty.Title) + memoData := fmt.Sprintf("Payment For: %ss", bounty.Title) + memoText := url.QueryEscape(memoData) expectedUrl := fmt.Sprintf("%s/payment", config.RelayUrl) expectedBody := fmt.Sprintf(`{"amount": %d, "destination_key": "%s", "text": "memotext added for notification", "data": "%s"}`, bountyAmount, person.OwnerPubKey, memoText)