gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] 07/07: helper that returns a bank configuration, given the ho


From: gnunet
Subject: [libeufin] 07/07: helper that returns a bank configuration, given the hostname.
Date: Tue, 29 Jun 2021 15:59:18 +0200

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

ms pushed a commit to branch master
in repository libeufin.

commit 786b70a1327066bc5670aa6ccc0c5f4f2ec6ed1c
Author: ms <ms@taler.net>
AuthorDate: Tue Jun 29 13:50:16 2021 +0200

    helper that returns a bank configuration, given the hostname.
---
 sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt |  2 ++
 .../main/kotlin/tech/libeufin/sandbox/Helpers.kt    | 21 +++++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
index 9878790..99bed21 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
@@ -92,6 +92,7 @@ object SandboxConfigsTable : LongIdTable() {
     val allowRegistrations = bool("allowRegistrations")
     val bankDebtLimit = integer("bankDebtLimit")
     val usersDebtLimit = integer("usersDebtLimit")
+    val hostname = text("hostname")
 }
 
 class SandboxConfigEntity(id: EntityID<Long>) : LongEntity(id) {
@@ -100,6 +101,7 @@ class SandboxConfigEntity(id: EntityID<Long>) : 
LongEntity(id) {
     var allowRegistrations by SandboxConfigsTable.allowRegistrations
     var bankDebtLimit by SandboxConfigsTable.bankDebtLimit
     var usersDebtLimit by SandboxConfigsTable.usersDebtLimit
+    var name by SandboxConfigsTable.hostname
 }
 
 object SandboxUsersTable : LongIdTable() {
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt
index 75448f9..7f7d7aa 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Helpers.kt
@@ -75,6 +75,27 @@ fun getBankAccountFromSubscriber(subscriber: 
EbicsSubscriberEntity): BankAccount
         )
     }
 }
+
+/**
+ * Fetch a configuration for Sandbox, corresponding to the host that runs the 
service.
+ */
+fun getSandboxConfig(hostname: String?): SandboxConfigEntity {
+    var ret: SandboxConfigEntity? = transaction {
+        if (hostname == null) {
+            SandboxConfigEntity.all().firstOrNull()
+        } else {
+            SandboxConfigEntity.find {
+                SandboxConfigsTable.hostname eq hostname
+            }.firstOrNull()
+        }
+    }
+    if (ret == null) throw SandboxError(
+        HttpStatusCode.InternalServerError,
+        "Serving from a non configured host"
+    )
+    return ret
+}
+
 fun getEbicsSubscriberFromDetails(userID: String, partnerID: String, hostID: 
String): EbicsSubscriberEntity {
     return transaction {
         EbicsSubscriberEntity.find {

-- 
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]