From 686c46bf784b0393dcc94a5fae4933008fa71b9c Mon Sep 17 00:00:00 2001 From: stuzer05 Date: Mon, 4 Nov 2024 21:58:44 +0200 Subject: [PATCH] Add docker deploy --- webhook.go | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/webhook.go b/webhook.go index 0506eaf..cba25d1 100644 --- a/webhook.go +++ b/webhook.go @@ -9,6 +9,10 @@ import ( ) func handleWebhook(w http.ResponseWriter, r *http.Request) { + // Parse URL query parameters + queryParams := r.URL.Query() + isRetry := queryParams.Get("retry") == "true" + // read request body bytes body, err := io.ReadAll(r.Body) if err != nil { @@ -36,14 +40,16 @@ func handleWebhook(w http.ResponseWriter, r *http.Request) { return } - // check if transaction hs been logged - isTransactionAlreadyLogged, err := app.LogContainsTransactionID(monobankTransaction.Data.StatementItem.Id) - if err != nil { - app.LogString(err.Error()) - return - } - if isTransactionAlreadyLogged { - return + // only check for logged transaction if not a retry + if !isRetry { + isTransactionAlreadyLogged, err := app.LogContainsTransactionID(monobankTransaction.Data.StatementItem.Id) + if err != nil { + app.LogString(err.Error()) + return + } + if isTransactionAlreadyLogged { + return + } } err = app.ImportTransaction(monobankTransaction)