Fix webhook transactions never been logging

This commit is contained in:
Illya Marchenko 2024-09-07 11:38:02 +03:00
parent 25212fbd1c
commit cd31de87e5
Signed by: stuzer05
GPG Key ID: A6ABAAA9268F9F4F
2 changed files with 10 additions and 9 deletions

@ -29,15 +29,6 @@ func ImportTransaction(monobankTransaction monobank.WebHookResponse) error {
return err return err
} }
// check if transaction hs been logged
isTransactionAlreadyLogged, err := LogContainsTransactionID(monobankTransaction.Data.StatementItem.Id)
if err != nil {
return err
}
if isTransactionAlreadyLogged {
return nil
}
// find accounts // find accounts
destAccount := App().Config.GetAccountByMonobankId(monobankTransaction.Data.Account) destAccount := App().Config.GetAccountByMonobankId(monobankTransaction.Data.Account)

@ -36,6 +36,16 @@ func handleWebhook(w http.ResponseWriter, r *http.Request) {
return 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
}
err = app.ImportTransaction(monobankTransaction) err = app.ImportTransaction(monobankTransaction)
if err != nil { if err != nil {
app.LogString(err.Error()) app.LogString(err.Error())