commit fbf42e3a6d45a224481cb3ca7fa96056554d4469
parent 916a3189ce3c4852dbf498b4cf6fa96ba9f9f1de
Author: MS <ms@taler.net>
Date: Tue, 26 Jan 2021 18:31:06 +0100
fix task deletion
Diffstat:
1 file changed, 13 insertions(+), 15 deletions(-)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
@@ -480,26 +480,24 @@ fun serverMain(dbName: String, host: String, port: Int) {
get("/bank-accounts/{accountId}/schedule/{taskId}") {
requireSuperuser(call.request)
+ val taskId = ensureNonNull(call.parameters["taskId"])
val task = transaction {
NexusScheduledTaskEntity.find {
- NexusScheduledTasksTable.taskName eq ensureNonNull(call.parameters["taskId"])
+ NexusScheduledTasksTable.taskName eq taskId
}.firstOrNull()
}
+ if (task == null) throw NexusError(HttpStatusCode.NotFound, "Task ${taskId} wasn't found")
call.respond(
- if (task != null) {
- AccountTask(
- resourceId = task.resourceId,
- resourceType = task.resourceType,
- taskName = task.taskName,
- taskCronspec = task.taskCronspec,
- taskType = task.taskType,
- taskParams = task.taskParams,
- nextScheduledExecutionSec = task.nextScheduledExecutionSec,
- prevScheduledExecutionSec = task.prevScheduledExecutionSec
- )
- } else {
- object {}
- }
+ AccountTask(
+ resourceId = task.resourceId,
+ resourceType = task.resourceType,
+ taskName = task.taskName,
+ taskCronspec = task.taskCronspec,
+ taskType = task.taskType,
+ taskParams = task.taskParams,
+ nextScheduledExecutionSec = task.nextScheduledExecutionSec,
+ prevScheduledExecutionSec = task.prevScheduledExecutionSec
+ )
)
return@get
}