commit d8bb66f402e4aebf3c091bd31dcbadd6cb1995b9 parent 683b4754d05f9f762dcaf736df4fcb11ce2e60eb Author: MS <ms@taler.net> Date: Thu, 28 May 2020 14:49:22 +0200 store facade data Diffstat:
| M | nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt | | | 2 | +- |
| M | nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | | | 19 | ++++++++++++++----- |
2 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt @@ -280,7 +280,7 @@ object FacadesTable : IdTable<String>() { val bankAccountsWrite = text("bankAccountsWrite") val bankConnectionsRead = text("bankConnectionsRead") val bankConnectionsWrite = text("bankConnectionsWrite") - val config = blob("config") + val config = blob("config").nullable() /* what's the best format to store Any? */ } class FacadeEntity(id: EntityID<String>) : Entity<String>(id) { diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt @@ -949,14 +949,23 @@ fun serverMain(dbName: String) { } post("/facades") { val body = call.receive<FacadeInfo>() - /** - * db work here. - */ - + val user = authenticateRequest(call.request) + if (user.id.value != body.creator) throw NexusError( + HttpStatusCode.BadRequest, "Facade creator != authenticated user" + ) + transaction { + FacadeEntity.new(body.name) { + type = body.type + creator = user + bankAccountsRead = body.bankAccountsRead.joinToString("|") + bankAccountsWrite = body.bankAccountsWrite.joinToString("|") + bankConnectionsRead = body.bankConnectionsRead.joinToString("|") + bankConnectionsWrite = body.bankConnectionsWrite.joinToString("|") + } + } call.respondText("Facade created") return@post } - /** * Hello endpoint. */