Merge branch 'main' into feature/share-images-via-small-talk
This commit is contained in:
commit
a06c00eea4
|
@ -91,7 +91,7 @@ ext.Dependencies.with {
|
|||
def kotlinVer = "1.6.10"
|
||||
def sqldelightVer = "1.5.3"
|
||||
def composeVer = "1.1.0"
|
||||
def ktorVer = "2.0.1"
|
||||
def ktorVer = "2.0.2"
|
||||
|
||||
google = new DependenciesContainer()
|
||||
google.with {
|
||||
|
@ -110,7 +110,7 @@ ext.Dependencies.with {
|
|||
kotlinGradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVer}"
|
||||
kotlinSerializationGradlePlugin = "org.jetbrains.kotlin:kotlin-serialization:${kotlinVer}"
|
||||
kotlinSerializationJson = "org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.3"
|
||||
kotlinCoroutinesCore = "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1"
|
||||
kotlinCoroutinesCore = "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.2"
|
||||
kotlinCoroutinesTest = 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.2'
|
||||
kotlinTest = "org.jetbrains.kotlin:kotlin-test-junit:${kotlinVer}"
|
||||
|
||||
|
@ -123,8 +123,10 @@ ext.Dependencies.with {
|
|||
ktorAndroid = "io.ktor:ktor-client-android:${ktorVer}"
|
||||
ktorCore = "io.ktor:ktor-client-core:${ktorVer}"
|
||||
ktorSerialization = "io.ktor:ktor-client-serialization:${ktorVer}"
|
||||
ktorJson = "io.ktor:ktor-serialization-kotlinx-json:${ktorVer}"
|
||||
ktorLogging = "io.ktor:ktor-client-logging-jvm:${ktorVer}"
|
||||
ktorJava = "io.ktor:ktor-client-java:${ktorVer}"
|
||||
ktorContentNegotiation = "io.ktor:ktor-client-content-negotiation:${ktorVer}"
|
||||
|
||||
coil = "io.coil-kt:coil-compose:2.1.0"
|
||||
accompanistSystemuicontroller = "com.google.accompanist:accompanist-systemuicontroller:0.24.9-beta"
|
||||
|
|
|
@ -9,5 +9,6 @@ dependencies {
|
|||
implementation Dependencies.mavenCentral.ktorCore
|
||||
implementation Dependencies.mavenCentral.ktorSerialization
|
||||
implementation Dependencies.mavenCentral.ktorLogging
|
||||
implementation Dependencies.mavenCentral.kotlinSerializationJson
|
||||
implementation Dependencies.mavenCentral.ktorContentNegotiation
|
||||
implementation Dependencies.mavenCentral.ktorJson
|
||||
}
|
|
@ -4,9 +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.plugins.json.*
|
||||
import io.ktor.client.plugins.kotlinx.serializer.*
|
||||
import io.ktor.client.plugins.contentnegotiation.*
|
||||
import io.ktor.client.plugins.logging.*
|
||||
import io.ktor.serialization.kotlinx.json.*
|
||||
import kotlinx.serialization.json.Json
|
||||
|
||||
class KtorMatrixHttpClientFactory(
|
||||
|
@ -14,10 +14,10 @@ class KtorMatrixHttpClientFactory(
|
|||
private val includeLogging: Boolean,
|
||||
) : MatrixHttpClient.Factory {
|
||||
|
||||
override fun create(json: Json): MatrixHttpClient {
|
||||
override fun create(jsonInstance: Json): MatrixHttpClient {
|
||||
val client = HttpClient {
|
||||
install(JsonPlugin) {
|
||||
serializer = KotlinxSerializer(json)
|
||||
install(ContentNegotiation) {
|
||||
json(jsonInstance)
|
||||
}
|
||||
expectSuccess = true
|
||||
if (includeLogging) {
|
||||
|
|
|
@ -42,16 +42,16 @@ internal fun registerRequest(userName: String, password: String, baseUrl: String
|
|||
baseUrl = baseUrl,
|
||||
)
|
||||
|
||||
internal fun wellKnownRequest(baseUrl: String) = httpRequest<String>(
|
||||
internal fun wellKnownRequest(baseUrl: String) = httpRequest<RawResponse>(
|
||||
path = ".well-known/matrix/client",
|
||||
method = MatrixHttpClient.Method.GET,
|
||||
baseUrl = baseUrl,
|
||||
authenticated = false,
|
||||
)
|
||||
|
||||
@JvmInline
|
||||
@Serializable
|
||||
internal value class RawResponse(val value: String)
|
||||
typealias RawResponse = ByteArray
|
||||
|
||||
fun RawResponse.readString() = this.toString(Charsets.UTF_8)
|
||||
|
||||
internal data class Auth(
|
||||
val session: String,
|
||||
|
|
|
@ -6,6 +6,7 @@ import io.ktor.http.*
|
|||
import kotlinx.serialization.SerializationException
|
||||
import kotlinx.serialization.json.Json
|
||||
import java.net.UnknownHostException
|
||||
import java.nio.charset.Charset
|
||||
|
||||
internal typealias FetchWellKnownUseCase = suspend (String) -> WellKnownResult
|
||||
|
||||
|
@ -17,7 +18,7 @@ internal class FetchWellKnownUseCaseImpl(
|
|||
override suspend fun invoke(domainUrl: String): WellKnownResult {
|
||||
return runCatching {
|
||||
val rawResponse = httpClient.execute(rawWellKnownRequestForServersWithoutContentTypes(domainUrl))
|
||||
json.decodeFromString(ApiWellKnown.serializer(), rawResponse)
|
||||
json.decodeFromString(ApiWellKnown.serializer(), rawResponse.readString())
|
||||
}
|
||||
.fold(
|
||||
onSuccess = { WellKnownResult.Success(it) },
|
||||
|
|
Loading…
Reference in New Issue