gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] branch master updated: Telling how many new transactions arri


From: gnunet
Subject: [libeufin] branch master updated: Telling how many new transactions arrived from bank.
Date: Tue, 12 Jan 2021 18:15:37 +0100

This is an automated email from the git hooks/post-receive script.

ms pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new 7794a6b  Telling how many new transactions arrived from bank.
7794a6b is described below

commit 7794a6b2c1e7bcd79a242605337cd36004983456
Author: MS <ms@taler.net>
AuthorDate: Tue Jan 12 18:15:08 2021 +0100

    Telling how many new transactions arrived from bank.
---
 .../main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt | 10 +++++++---
 .../src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt  |  8 ++------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git 
a/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt
index 52a9d2c..3385e61 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt
@@ -207,7 +207,8 @@ fun processCamtMessage(bankAccountId: String, camtDoc: 
Document, code: String):
  * Create new transactions for an account based on bank messages it
  * did not see before.
  */
-fun ingestBankMessagesIntoAccount(bankConnectionId: String, bankAccountId: 
String) {
+fun ingestBankMessagesIntoAccount(bankConnectionId: String, bankAccountId: 
String): Int {
+    var totalNew = 0
     transaction {
         val conn = NexusBankConnectionEntity.findById(bankConnectionId)
         if (conn == null) {
@@ -222,6 +223,7 @@ fun ingestBankMessagesIntoAccount(bankConnectionId: String, 
bankAccountId: Strin
             (NexusBankMessagesTable.bankConnection eq conn.id) and
                     (NexusBankMessagesTable.id greater 
acct.highestSeenBankMessageId)
         }.orderBy(Pair(NexusBankMessagesTable.id, SortOrder.ASC)).forEach {
+            totalNew++
             val doc = 
XMLUtil.parseStringIntoDom(it.message.bytes.toString(Charsets.UTF_8))
             if (!processCamtMessage(bankAccountId, doc, it.code)) {
                 it.errors = true
@@ -231,6 +233,7 @@ fun ingestBankMessagesIntoAccount(bankConnectionId: String, 
bankAccountId: Strin
         }
         acct.highestSeenBankMessageId = lastId
     }
+    return totalNew
 }
 
 /**
@@ -280,7 +283,7 @@ suspend fun fetchBankAccountTransactions(
     client: HttpClient,
     fetchSpec: FetchSpecJson,
     accountId: String
-) {
+): Int {
     val res = transaction {
         val acct = NexusBankAccountEntity.findById(accountId)
         if (acct == null) {
@@ -315,8 +318,9 @@ suspend fun fetchBankAccountTransactions(
             "Connection type '${res.connectionType}' not implemented"
         )
     }
-    ingestBankMessagesIntoAccount(res.connectionName, accountId)
+    val newMessages = ingestBankMessagesIntoAccount(res.connectionName, 
accountId)
     ingestTalerTransactions()
+    return newMessages
 }
 
 fun importBankAccount(call: ApplicationCall, offeredBankAccountId: String, 
nexusBankAccountId: String) {
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
index bfeee9c..4ac9037 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
@@ -650,12 +650,8 @@ fun serverMain(dbName: String, host: String, port: Int) {
                         null
                     )
                 }
-                fetchBankAccountTransactions(
-                    client,
-                    fetchSpec,
-                    accountid
-                )
-                call.respond(object {})
+                val newMessages = fetchBankAccountTransactions(client, 
fetchSpec, accountid)
+                call.respond(object {val newMessages = newMessages})
                 return@post
             }
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]