From 70bfaf2d8eda4df3c41cb2b3cd16ab2570b35ac9 Mon Sep 17 00:00:00 2001 From: Lukas Forst Date: Sun, 1 Mar 2020 20:22:55 +0100 Subject: [PATCH] update versions of libraries and fix hanlding service --- build.gradle.kts | 39 ++++++++++--------- gradle.properties | 3 -- .../polls/services/MessagesHandlingService.kt | 5 ++- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index bfe3613..a997377 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -15,40 +15,41 @@ repositories { jcenter() } -val ktorVersion: String by project -val ktoolzVersion: String by project - dependencies { // stdlib implementation(kotlin("stdlib-jdk8")) // extension functions - implementation("ai.blindspot.ktoolz:ktoolz:$ktoolzVersion") + implementation("ai.blindspot.ktoolz", "ktoolz", "1.0.3") // Ktor server dependencies - implementation("io.ktor:ktor-server-core:$ktorVersion") - implementation("io.ktor:ktor-server-netty:$ktorVersion") - implementation("io.ktor:ktor-jackson:$ktorVersion") - implementation("io.ktor:ktor-websockets:$ktorVersion") + val ktorVersion = "1.3.0" + implementation("io.ktor", "ktor-server-core", ktorVersion) + implementation("io.ktor", "ktor-server-netty", ktorVersion) + implementation("io.ktor", "ktor-jackson", ktorVersion) + implementation("io.ktor", "ktor-websockets", ktorVersion) // Ktor client dependencies - implementation("io.ktor:ktor-client-json:$ktorVersion") - implementation("io.ktor:ktor-client-jackson:$ktorVersion") - implementation("io.ktor:ktor-client-websockets:$ktorVersion") - implementation("io.ktor:ktor-client-cio:$ktorVersion") + implementation("io.ktor", "ktor-client-json", ktorVersion) + implementation("io.ktor", "ktor-client-jackson", ktorVersion) + implementation("io.ktor", "ktor-client-websockets", ktorVersion) + implementation("io.ktor", "ktor-client-cio", ktorVersion) // logging - implementation("io.github.microutils:kotlin-logging:1.7.8") - implementation("org.slf4j:slf4j-simple:1.6.1") + implementation("io.github.microutils", "kotlin-logging", "1.7.8") + implementation("org.slf4j", "slf4j-simple", "1.6.1") // DI - implementation("org.kodein.di:kodein-di-generic-jvm:6.5.0") - implementation("org.kodein.di:kodein-di-framework-ktor-server-jvm:6.5.0") + val kodeinVersion = "6.5.0" + implementation("org.kodein.di", "kodein-di-generic-jvm", kodeinVersion) + implementation("org.kodein.di", "kodein-di-framework-ktor-server-jvm", kodeinVersion) // database implementation("org.postgresql", "postgresql", "42.2.2") - implementation("org.jetbrains.exposed", "exposed-core", "0.20.1") - implementation("org.jetbrains.exposed", "exposed-dao", "0.20.1") - implementation("org.jetbrains.exposed", "exposed-jdbc", "0.20.1") + + val exposedVersion = "0.20.1" + implementation("org.jetbrains.exposed", "exposed-core", exposedVersion) + implementation("org.jetbrains.exposed", "exposed-dao", exposedVersion) + implementation("org.jetbrains.exposed", "exposed-jdbc", exposedVersion) } tasks { diff --git a/gradle.properties b/gradle.properties index 5372281..7fc6f1f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1 @@ kotlin.code.style=official - -ktoolzVersion=1.0.1 -ktorVersion=1.3.0 diff --git a/src/main/kotlin/com/wire/bots/polls/services/MessagesHandlingService.kt b/src/main/kotlin/com/wire/bots/polls/services/MessagesHandlingService.kt index bbf35bf..3c2c82f 100644 --- a/src/main/kotlin/com/wire/bots/polls/services/MessagesHandlingService.kt +++ b/src/main/kotlin/com/wire/bots/polls/services/MessagesHandlingService.kt @@ -46,7 +46,10 @@ class MessagesHandlingService( } private suspend fun handleText(token: String, message: Message) { - val userInput = UsersInput(requireNotNull(message.text) { "Text message received, text field can not be null!" }) + val userInput = UsersInput( + userId = requireNotNull(message.userId) { "User ID must be specified for the text message." }, + input = requireNotNull(message.text) { "Text message received, text field can not be null!" } + ) with(userInput.input) { when { startsWith("/poll") -> pollService.createPoll(token, userInput)