fixing 2.0 compile errors
This commit is contained in:
parent
05a74b1270
commit
cec21f2c6e
|
@ -55,7 +55,7 @@ import app.dapk.st.work.TaskRunnerModule
|
||||||
import app.dapk.st.work.WorkModule
|
import app.dapk.st.work.WorkModule
|
||||||
import app.dapk.st.work.WorkScheduler
|
import app.dapk.st.work.WorkScheduler
|
||||||
import com.squareup.sqldelight.android.AndroidSqliteDriver
|
import com.squareup.sqldelight.android.AndroidSqliteDriver
|
||||||
import io.ktor.client.features.*
|
import io.ktor.client.plugins.*
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import java.time.Clock
|
import java.time.Clock
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,9 @@ import app.dapk.st.matrix.common.CredentialsStore
|
||||||
import app.dapk.st.matrix.http.MatrixHttpClient
|
import app.dapk.st.matrix.http.MatrixHttpClient
|
||||||
import app.dapk.st.matrix.http.ktor.internal.KtorMatrixHttpClient
|
import app.dapk.st.matrix.http.ktor.internal.KtorMatrixHttpClient
|
||||||
import io.ktor.client.*
|
import io.ktor.client.*
|
||||||
import io.ktor.client.features.json.*
|
import io.ktor.client.plugins.json.*
|
||||||
import io.ktor.client.features.json.serializer.*
|
import io.ktor.client.plugins.kotlinx.serializer.*
|
||||||
import io.ktor.client.features.logging.*
|
import io.ktor.client.plugins.logging.*
|
||||||
import io.ktor.http.*
|
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
|
|
||||||
class KtorMatrixHttpClientFactory(
|
class KtorMatrixHttpClientFactory(
|
||||||
|
@ -17,10 +16,10 @@ class KtorMatrixHttpClientFactory(
|
||||||
|
|
||||||
override fun create(json: Json): MatrixHttpClient {
|
override fun create(json: Json): MatrixHttpClient {
|
||||||
val client = HttpClient {
|
val client = HttpClient {
|
||||||
install(JsonFeature) {
|
install(JsonPlugin) {
|
||||||
serializer = KotlinxSerializer(json)
|
serializer = KotlinxSerializer(json)
|
||||||
}
|
}
|
||||||
|
expectSuccess = true
|
||||||
if (includeLogging) {
|
if (includeLogging) {
|
||||||
install(Logging) {
|
install(Logging) {
|
||||||
logger = Logger.SIMPLE
|
logger = Logger.SIMPLE
|
||||||
|
|
|
@ -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
|
||||||
import app.dapk.st.matrix.http.MatrixHttpClient.Method
|
import app.dapk.st.matrix.http.MatrixHttpClient.Method
|
||||||
import io.ktor.client.*
|
import io.ktor.client.*
|
||||||
import io.ktor.client.features.*
|
import io.ktor.client.plugins.*
|
||||||
import io.ktor.client.request.*
|
import io.ktor.client.request.*
|
||||||
import io.ktor.client.statement.*
|
|
||||||
import io.ktor.http.*
|
import io.ktor.http.*
|
||||||
|
import io.ktor.util.*
|
||||||
|
|
||||||
internal class KtorMatrixHttpClient(
|
internal class KtorMatrixHttpClient(
|
||||||
private val client: HttpClient,
|
private val client: HttpClient,
|
||||||
|
@ -67,6 +67,7 @@ internal class KtorMatrixHttpClient(
|
||||||
// return tokenResult.accessToken
|
// return tokenResult.accessToken
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(InternalAPI::class)
|
||||||
private fun <T> HttpRequestBuilder.buildRequest(
|
private fun <T> HttpRequestBuilder.buildRequest(
|
||||||
credentials: UserCredentials?,
|
credentials: UserCredentials?,
|
||||||
request: MatrixHttpClient.HttpRequest<T>
|
request: MatrixHttpClient.HttpRequest<T>
|
||||||
|
@ -100,7 +101,7 @@ internal class KtorMatrixHttpClient(
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
private suspend fun <T> MatrixHttpClient.HttpRequest<T>.execute(requestBuilder: HttpRequestBuilder.() -> Unit): T {
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import app.dapk.st.matrix.common.CredentialsStore
|
||||||
import app.dapk.st.matrix.common.UserCredentials
|
import app.dapk.st.matrix.common.UserCredentials
|
||||||
import app.dapk.st.matrix.http.MatrixHttpClient
|
import app.dapk.st.matrix.http.MatrixHttpClient
|
||||||
import app.dapk.st.matrix.http.ensureTrailingSlash
|
import app.dapk.st.matrix.http.ensureTrailingSlash
|
||||||
import io.ktor.client.features.*
|
import io.ktor.client.plugins.*
|
||||||
import io.ktor.client.statement.*
|
import io.ktor.client.statement.*
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
@ -28,7 +28,7 @@ class RegisterUseCase(
|
||||||
} catch (error: ClientRequestException) {
|
} catch (error: ClientRequestException) {
|
||||||
when (error.response.status.value) {
|
when (error.response.status.value) {
|
||||||
401 -> {
|
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" } }
|
val supportsDummy = stage0.flows.any { it.stages.any { it == "m.login.dummy" } }
|
||||||
if (supportsDummy) {
|
if (supportsDummy) {
|
||||||
registerAccount(userName, password, baseUrl, stage0.session)
|
registerAccount(userName, password, baseUrl, stage0.session)
|
||||||
|
|
Loading…
Reference in New Issue