diff --git a/app/src/main/kotlin/app/dapk/st/graph/AppModule.kt b/app/src/main/kotlin/app/dapk/st/graph/AppModule.kt index 9473221..44f731d 100644 --- a/app/src/main/kotlin/app/dapk/st/graph/AppModule.kt +++ b/app/src/main/kotlin/app/dapk/st/graph/AppModule.kt @@ -55,7 +55,7 @@ import app.dapk.st.work.TaskRunnerModule import app.dapk.st.work.WorkModule import app.dapk.st.work.WorkScheduler import com.squareup.sqldelight.android.AndroidSqliteDriver -import io.ktor.client.features.* +import io.ktor.client.plugins.* import kotlinx.coroutines.Dispatchers import java.time.Clock diff --git a/matrix/matrix-http-ktor/src/main/kotlin/app/dapk/st/matrix/http/ktor/KtorMatrixHttpClientFactory.kt b/matrix/matrix-http-ktor/src/main/kotlin/app/dapk/st/matrix/http/ktor/KtorMatrixHttpClientFactory.kt index 2ccb558..e038291 100644 --- a/matrix/matrix-http-ktor/src/main/kotlin/app/dapk/st/matrix/http/ktor/KtorMatrixHttpClientFactory.kt +++ b/matrix/matrix-http-ktor/src/main/kotlin/app/dapk/st/matrix/http/ktor/KtorMatrixHttpClientFactory.kt @@ -4,10 +4,9 @@ import app.dapk.st.matrix.common.CredentialsStore import app.dapk.st.matrix.http.MatrixHttpClient import app.dapk.st.matrix.http.ktor.internal.KtorMatrixHttpClient import io.ktor.client.* -import io.ktor.client.features.json.* -import io.ktor.client.features.json.serializer.* -import io.ktor.client.features.logging.* -import io.ktor.http.* +import io.ktor.client.plugins.json.* +import io.ktor.client.plugins.kotlinx.serializer.* +import io.ktor.client.plugins.logging.* import kotlinx.serialization.json.Json class KtorMatrixHttpClientFactory( @@ -17,10 +16,10 @@ class KtorMatrixHttpClientFactory( override fun create(json: Json): MatrixHttpClient { val client = HttpClient { - install(JsonFeature) { + install(JsonPlugin) { serializer = KotlinxSerializer(json) } - + expectSuccess = true if (includeLogging) { install(Logging) { logger = Logger.SIMPLE diff --git a/matrix/matrix-http-ktor/src/main/kotlin/app/dapk/st/matrix/http/ktor/internal/KtorMatrixHttpClient.kt b/matrix/matrix-http-ktor/src/main/kotlin/app/dapk/st/matrix/http/ktor/internal/KtorMatrixHttpClient.kt index fe2725b..5cb157e 100644 --- a/matrix/matrix-http-ktor/src/main/kotlin/app/dapk/st/matrix/http/ktor/internal/KtorMatrixHttpClient.kt +++ b/matrix/matrix-http-ktor/src/main/kotlin/app/dapk/st/matrix/http/ktor/internal/KtorMatrixHttpClient.kt @@ -5,10 +5,10 @@ import app.dapk.st.matrix.common.UserCredentials import app.dapk.st.matrix.http.MatrixHttpClient import app.dapk.st.matrix.http.MatrixHttpClient.Method import io.ktor.client.* -import io.ktor.client.features.* +import io.ktor.client.plugins.* import io.ktor.client.request.* -import io.ktor.client.statement.* import io.ktor.http.* +import io.ktor.util.* internal class KtorMatrixHttpClient( private val client: HttpClient, @@ -67,6 +67,7 @@ internal class KtorMatrixHttpClient( // return tokenResult.accessToken } + @OptIn(InternalAPI::class) private fun HttpRequestBuilder.buildRequest( credentials: UserCredentials?, request: MatrixHttpClient.HttpRequest @@ -100,7 +101,7 @@ internal class KtorMatrixHttpClient( @Suppress("UNCHECKED_CAST") private suspend fun MatrixHttpClient.HttpRequest.execute(requestBuilder: HttpRequestBuilder.() -> Unit): T { - return client.request { requestBuilder(this) }.call.receive(this.typeInfo) as T + return client.request { requestBuilder(this) }.call.body(this.typeInfo) as T } } diff --git a/matrix/services/auth/src/main/kotlin/app/dapk/st/matrix/auth/internal/RegisterUseCase.kt b/matrix/services/auth/src/main/kotlin/app/dapk/st/matrix/auth/internal/RegisterUseCase.kt index e3438ab..320ab3b 100644 --- a/matrix/services/auth/src/main/kotlin/app/dapk/st/matrix/auth/internal/RegisterUseCase.kt +++ b/matrix/services/auth/src/main/kotlin/app/dapk/st/matrix/auth/internal/RegisterUseCase.kt @@ -5,7 +5,7 @@ import app.dapk.st.matrix.common.CredentialsStore import app.dapk.st.matrix.common.UserCredentials import app.dapk.st.matrix.http.MatrixHttpClient import app.dapk.st.matrix.http.ensureTrailingSlash -import io.ktor.client.features.* +import io.ktor.client.plugins.* import io.ktor.client.statement.* import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -28,7 +28,7 @@ class RegisterUseCase( } catch (error: ClientRequestException) { when (error.response.status.value) { 401 -> { - val stage0 = json.decodeFromString(ApiUserInteractive.serializer(), error.response.readText()) + val stage0 = json.decodeFromString(ApiUserInteractive.serializer(), error.response.bodyAsText()) val supportsDummy = stage0.flows.any { it.stages.any { it == "m.login.dummy" } } if (supportsDummy) { registerAccount(userName, password, baseUrl, stage0.session)