mirror of
https://github.com/ouchadam/small-talk.git
synced 2025-02-14 03:00:53 +01:00
Merge pull request #48 from ouchadam/dependabot/gradle/ktorVer-2.0.2
Bump ktorVer from 2.0.1 to 2.0.2
This commit is contained in:
commit
f80c829010
@ -91,7 +91,7 @@ ext.Dependencies.with {
|
|||||||
def kotlinVer = "1.6.10"
|
def kotlinVer = "1.6.10"
|
||||||
def sqldelightVer = "1.5.3"
|
def sqldelightVer = "1.5.3"
|
||||||
def composeVer = "1.1.0"
|
def composeVer = "1.1.0"
|
||||||
def ktorVer = "2.0.1"
|
def ktorVer = "2.0.2"
|
||||||
|
|
||||||
google = new DependenciesContainer()
|
google = new DependenciesContainer()
|
||||||
google.with {
|
google.with {
|
||||||
@ -123,8 +123,10 @@ ext.Dependencies.with {
|
|||||||
ktorAndroid = "io.ktor:ktor-client-android:${ktorVer}"
|
ktorAndroid = "io.ktor:ktor-client-android:${ktorVer}"
|
||||||
ktorCore = "io.ktor:ktor-client-core:${ktorVer}"
|
ktorCore = "io.ktor:ktor-client-core:${ktorVer}"
|
||||||
ktorSerialization = "io.ktor:ktor-client-serialization:${ktorVer}"
|
ktorSerialization = "io.ktor:ktor-client-serialization:${ktorVer}"
|
||||||
|
ktorJson = "io.ktor:ktor-serialization-kotlinx-json:${ktorVer}"
|
||||||
ktorLogging = "io.ktor:ktor-client-logging-jvm:${ktorVer}"
|
ktorLogging = "io.ktor:ktor-client-logging-jvm:${ktorVer}"
|
||||||
ktorJava = "io.ktor:ktor-client-java:${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"
|
coil = "io.coil-kt:coil-compose:2.1.0"
|
||||||
accompanistSystemuicontroller = "com.google.accompanist:accompanist-systemuicontroller:0.24.9-beta"
|
accompanistSystemuicontroller = "com.google.accompanist:accompanist-systemuicontroller:0.24.9-beta"
|
||||||
|
@ -9,5 +9,6 @@ dependencies {
|
|||||||
implementation Dependencies.mavenCentral.ktorCore
|
implementation Dependencies.mavenCentral.ktorCore
|
||||||
implementation Dependencies.mavenCentral.ktorSerialization
|
implementation Dependencies.mavenCentral.ktorSerialization
|
||||||
implementation Dependencies.mavenCentral.ktorLogging
|
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.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.plugins.json.*
|
import io.ktor.client.plugins.contentnegotiation.*
|
||||||
import io.ktor.client.plugins.kotlinx.serializer.*
|
|
||||||
import io.ktor.client.plugins.logging.*
|
import io.ktor.client.plugins.logging.*
|
||||||
|
import io.ktor.serialization.kotlinx.json.*
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
|
|
||||||
class KtorMatrixHttpClientFactory(
|
class KtorMatrixHttpClientFactory(
|
||||||
@ -14,10 +14,10 @@ class KtorMatrixHttpClientFactory(
|
|||||||
private val includeLogging: Boolean,
|
private val includeLogging: Boolean,
|
||||||
) : MatrixHttpClient.Factory {
|
) : MatrixHttpClient.Factory {
|
||||||
|
|
||||||
override fun create(json: Json): MatrixHttpClient {
|
override fun create(jsonInstance: Json): MatrixHttpClient {
|
||||||
val client = HttpClient {
|
val client = HttpClient {
|
||||||
install(JsonPlugin) {
|
install(ContentNegotiation) {
|
||||||
serializer = KotlinxSerializer(json)
|
json(jsonInstance)
|
||||||
}
|
}
|
||||||
expectSuccess = true
|
expectSuccess = true
|
||||||
if (includeLogging) {
|
if (includeLogging) {
|
||||||
|
@ -42,16 +42,16 @@ internal fun registerRequest(userName: String, password: String, baseUrl: String
|
|||||||
baseUrl = baseUrl,
|
baseUrl = baseUrl,
|
||||||
)
|
)
|
||||||
|
|
||||||
internal fun wellKnownRequest(baseUrl: String) = httpRequest<String>(
|
internal fun wellKnownRequest(baseUrl: String) = httpRequest<RawResponse>(
|
||||||
path = ".well-known/matrix/client",
|
path = ".well-known/matrix/client",
|
||||||
method = MatrixHttpClient.Method.GET,
|
method = MatrixHttpClient.Method.GET,
|
||||||
baseUrl = baseUrl,
|
baseUrl = baseUrl,
|
||||||
authenticated = false,
|
authenticated = false,
|
||||||
)
|
)
|
||||||
|
|
||||||
@JvmInline
|
typealias RawResponse = ByteArray
|
||||||
@Serializable
|
|
||||||
internal value class RawResponse(val value: String)
|
fun RawResponse.readString() = this.toString(Charsets.UTF_8)
|
||||||
|
|
||||||
internal data class Auth(
|
internal data class Auth(
|
||||||
val session: String,
|
val session: String,
|
||||||
|
@ -6,6 +6,7 @@ import io.ktor.http.*
|
|||||||
import kotlinx.serialization.SerializationException
|
import kotlinx.serialization.SerializationException
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import java.net.UnknownHostException
|
import java.net.UnknownHostException
|
||||||
|
import java.nio.charset.Charset
|
||||||
|
|
||||||
internal typealias FetchWellKnownUseCase = suspend (String) -> WellKnownResult
|
internal typealias FetchWellKnownUseCase = suspend (String) -> WellKnownResult
|
||||||
|
|
||||||
@ -17,7 +18,7 @@ internal class FetchWellKnownUseCaseImpl(
|
|||||||
override suspend fun invoke(domainUrl: String): WellKnownResult {
|
override suspend fun invoke(domainUrl: String): WellKnownResult {
|
||||||
return runCatching {
|
return runCatching {
|
||||||
val rawResponse = httpClient.execute(rawWellKnownRequestForServersWithoutContentTypes(domainUrl))
|
val rawResponse = httpClient.execute(rawWellKnownRequestForServersWithoutContentTypes(domainUrl))
|
||||||
json.decodeFromString(ApiWellKnown.serializer(), rawResponse)
|
json.decodeFromString(ApiWellKnown.serializer(), rawResponse.readString())
|
||||||
}
|
}
|
||||||
.fold(
|
.fold(
|
||||||
onSuccess = { WellKnownResult.Success(it) },
|
onSuccess = { WellKnownResult.Success(it) },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user