cashless2ecash

cashless2ecash: pay with cards for digital cash (experimental)
Log | Files | Refs | README

commit 878403ff395bf09406f5115855a21af2949800ea
parent 5356e9cd9374ca76a661fea65e4d701fc5bc94f0
Author: Joel-Haeberli <haebu@rubigen.ch>
Date:   Thu, 30 May 2024 08:49:08 +0200

fix: bank-integration request

Diffstat:
Mc2ec/api-bank-integration.go | 23+++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/c2ec/api-bank-integration.go b/c2ec/api-bank-integration.go @@ -244,30 +244,35 @@ func handleWithdrawalStatus(res http.ResponseWriter, req *http.Request) { ) if err != nil { - LogError("api-bank-integration", err) + LogError("bank-integration-api", err) errStat <- HTTP_INTERNAL_SERVER_ERROR } else { go listenFunc(timeoutCtx) } } else { wthdrl, stat := getWithdrawalOrError(wpd) - LogInfo("api-bank-integration", "loaded withdrawal") + LogInfo("bank-integration-api", "loaded withdrawal") if stat != HTTP_OK { - errStat <- stat + LogWarn("bank-integration-api", "tried loading withdrawal but got error") + //errStat <- stat + setLastResponseCodeForLogger(stat) + res.WriteHeader(stat) + return } else { + //w <- wthdrl res.Header().Add(CONTENT_TYPE_HEADER, "application/json") res.Write(wthdrl) return } } - for { + for wait := true; wait; { select { case <-timeoutCtx.Done(): LogInfo("bank-integration-api", "long poll time exceeded") setLastResponseCodeForLogger(HTTP_NO_CONTENT) res.WriteHeader(HTTP_NO_CONTENT) - return + wait = false case <-notifications: wthdrl, stat := getWithdrawalOrError(wpd) if stat != 200 { @@ -277,17 +282,19 @@ func handleWithdrawalStatus(res http.ResponseWriter, req *http.Request) { res.Header().Add(CONTENT_TYPE_HEADER, "application/json") res.Write(wthdrl) } - return + wait = false case wthdrl := <-w: res.Header().Add(CONTENT_TYPE_HEADER, "application/json") res.Write(wthdrl) - return + wait = false case status := <-errStat: + LogInfo("bank-integration-api", "got unsucessful state for withdrawal operation request") setLastResponseCodeForLogger(status) res.WriteHeader(status) - return + wait = false } } + LogInfo("bank-integration-api", "withdrawal operation status request finished") } func handleWithdrawalAbort(res http.ResponseWriter, req *http.Request) {