[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] 02/02: De- duplicator skeleton.
From: |
gnunet |
Subject: |
[libeufin] 02/02: De- duplicator skeleton. |
Date: |
Wed, 22 Apr 2020 18:39:30 +0200 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a commit to branch master
in repository libeufin.
commit c93c130bc393eec9eeae3178d5fe55bad4629414
Author: Marcello Stanisci <address@hidden>
AuthorDate: Wed Apr 22 18:38:06 2020 +0200
De- duplicator skeleton.
---
.idea/compiler.xml | 6 ++++++
nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt | 7 +++----
nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt | 16 +++++++++++++---
3 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..fb7f4a8
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="CompilerConfiguration">
+ <bytecodeTargetLevel target="11" />
+ </component>
+</project>
\ No newline at end of file
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
index f295fde..fa9c283 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
@@ -80,9 +80,8 @@ class TalerIncomingPaymentEntity(id: EntityID<Long>) :
LongEntity(id) {
}
/**
- * This table _assumes_ that all the entries have a BOOK status. The
- * current code however does only enforces this trusting the C53 response,
- * but never actually checking the appropriate "Sts" field.
+ * This table contains history "elements" as returned by the bank from a
+ * CAMT message. Therefore, any row could come from a C52/3/4 message
response.
*/
object EbicsRawBankTransactionsTable : LongIdTable() {
val nexusSubscriber = reference("subscriber", EbicsSubscribersTable)
@@ -97,7 +96,7 @@ object EbicsRawBankTransactionsTable : LongIdTable() {
val debitorName = text("debitorName")
val counterpartBic = text("counterpartBic")
val bookingDate = long("bookingDate")
- val status = text("status") // BOOK, ..
+ val status = text("status") // BOOK or other.
}
class EbicsRawBankTransactionEntity(id: EntityID<Long>) : LongEntity(id) {
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
index af9a95b..a77361e 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
@@ -203,6 +203,11 @@ class Taler(app: Route) {
return Gson().toJson(body)
}
+ /** Work in progress */
+ private fun duplicatePayment(entry: EbicsRawBankTransactionEntity):
Boolean {
+ return false
+ }
+
/** Attach Taler endpoints to the main Web server */
init {
@@ -385,16 +390,21 @@ class Taler(app: Route) {
transaction {
val subscriberAccount = getBankAccountsInfoFromId(id).first()
/**
- * Search for fresh INCOMING transactions having a BOOK
status. Cancellations and
- * other status changes will (1) be _appended_ to the payment
history, and (2) be
- * handled _independently_ by another dedicated routine.
+ * Search for fresh incoming payments in the raw table, and
making pointers
+ * from the Taler incoming payments table to the found fresh
payments.
*/
val latestIncomingPaymentId: Long =
TalerIncomingPaymentEntity.getLast()
EbicsRawBankTransactionEntity.find {
+ /** select payments having the exchange as the credited
party */
EbicsRawBankTransactionsTable.creditorIban eq
subscriberAccount.iban and
(EbicsRawBankTransactionsTable.status eq "BOOK")
and
+ /** avoid processing old payments from the raw
table */
(EbicsRawBankTransactionsTable.id.greater(latestIncomingPaymentId))
}.forEach {
+ if (duplicatePayment(it)) {
+ logger.warn("A duplicate payment situation is
happening")
+ throw NexusError(HttpStatusCode.InternalServerError,
"Duplicate payment situation")
+ }
if
(CryptoUtil.checkValidEddsaPublicKey(it.unstructuredRemittanceInformation)) {
TalerIncomingPaymentEntity.new {
payment = it
--
To stop receiving notification emails like this one, please contact
address@hidden.