[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated: allow querying bank messages
From: |
gnunet |
Subject: |
[libeufin] branch master updated: allow querying bank messages |
Date: |
Fri, 29 May 2020 10:27:20 +0200 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository libeufin.
The following commit(s) were added to refs/heads/master by this push:
new bf5ae27 allow querying bank messages
bf5ae27 is described below
commit bf5ae27dc73903fcac79b11569bd8c713e6cda16
Author: Florian Dold <florian.dold@gmail.com>
AuthorDate: Fri May 29 13:57:09 2020 +0530
allow querying bank messages
---
nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 50 +++++++++++++++++++++--
1 file changed, 46 insertions(+), 4 deletions(-)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
index f42af71..d9744f3 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -32,7 +32,6 @@ import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.ProgramResult
import com.github.ajalt.clikt.core.subcommands
import com.github.ajalt.clikt.parameters.arguments.argument
-import com.github.ajalt.clikt.parameters.arguments.default
import com.github.ajalt.clikt.parameters.options.default
import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.options.prompt
@@ -49,6 +48,7 @@ import io.ktor.http.HttpStatusCode
import io.ktor.jackson.jackson
import io.ktor.request.*
import io.ktor.response.respond
+import io.ktor.response.respondBytes
import io.ktor.response.respondText
import io.ktor.routing.*
import io.ktor.server.engine.embeddedServer
@@ -64,6 +64,7 @@ import org.slf4j.event.Level
import tech.libeufin.util.*
import tech.libeufin.util.CryptoUtil.hashpw
import tech.libeufin.util.ebics_h004.HTDResponseOrderData
+import java.lang.NumberFormatException
import java.net.URLEncoder
import java.util.*
import java.util.zip.InflaterInputStream
@@ -223,6 +224,22 @@ fun requireBankConnection(call: ApplicationCall,
parameterKey: String): NexusBan
return conn
}
+fun ApplicationRequest.hasBody(): Boolean {
+ if (this.isChunked()) {
+ return true
+ }
+ val contentLengthHeaderStr = this.headers["content-length"]
+ if (contentLengthHeaderStr != null) {
+ try {
+ val cl = contentLengthHeaderStr.toInt()
+ return cl != 0
+ } catch (e: NumberFormatException) {
+ return false;
+ }
+ }
+ return false
+}
+
fun serverMain(dbName: String) {
dbCreateTables(dbName)
val client = HttpClient {
@@ -548,10 +565,14 @@ fun serverMain(dbName: String) {
val subscriberDetails = subscriberDetails
}
}
- val body = call.receive<CollectedTransaction>()
+ val request = if (call.request.hasBody()) {
+ call.receive<CollectedTransaction>()
+ } else {
+ CollectedTransaction(null, null, null)
+ }
when (res.connectionType) {
"ebics" -> {
- fetchEbicsC5x("C53",client, res.connectionName,
body.start, body.end, res.subscriberDetails)
+ fetchEbicsC5x("C53",client, res.connectionName,
request.start, request.end, res.subscriberDetails)
ingestBankMessagesIntoAccount(res.connectionName,
accountid)
}
else -> throw NexusError(
@@ -794,8 +815,29 @@ fun serverMain(dbName: String) {
call.respond(ret)
}
+ get("/bank-connections/{connid}/messages/{msgid}") {
+ val ret = transaction {
+ val msgid = call.parameters["msgid"]
+ if (msgid == null || msgid == "") {
+ throw NexusError(HttpStatusCode.BadRequest, "missing
or invalid message ID")
+ }
+ val msg = NexusBankMessageEntity.find {
NexusBankMessagesTable.messageId eq msgid}.firstOrNull()
+ if (msg == null) {
+ throw NexusError(HttpStatusCode.NotFound, "bank
message not found")
+ }
+ return@transaction object {
+ val msgContent = msg.message.toByteArray()
+ }
+ }
+ call.respondBytes(ret.msgContent, ContentType("application",
"xml"))
+ }
+
post("/bank-connections/{connid}/ebics/fetch-c53") {
- val paramsJson = call.receiveOrNull<EbicsDateRangeJson>()
+ val paramsJson = if (call.request.hasBody()) {
+ call.receive<EbicsDateRangeJson>()
+ } else {
+ null
+ }
val ret = transaction {
val user = authenticateRequest(call.request)
val conn = requireBankConnection(call, "connid")
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libeufin] branch master updated: allow querying bank messages,
gnunet <=