fixing 2.0 compile errors

This commit is contained in:
Adam Brown 2022-04-12 22:27:05 +01:00
parent 05a74b1270
commit cec21f2c6e
4 changed files with 12 additions and 12 deletions

View File

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

View File

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

View File

@ -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 <T> HttpRequestBuilder.buildRequest(
credentials: UserCredentials?,
request: MatrixHttpClient.HttpRequest<T>
@ -100,7 +101,7 @@ internal class KtorMatrixHttpClient(
@Suppress("UNCHECKED_CAST")
private suspend fun <T> MatrixHttpClient.HttpRequest<T>.execute(requestBuilder: HttpRequestBuilder.() -> Unit): T {
return client.request<HttpResponse> { requestBuilder(this) }.call.receive(this.typeInfo) as T
return client.request { requestBuilder(this) }.call.body(this.typeInfo) as T
}
}

View File

@ -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)