mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-26 11:26:01 +03:00
Remove Riot ref: Riot -> Web client
This commit is contained in:
parent
7292c4e13d
commit
67f41028ff
3 changed files with 28 additions and 28 deletions
|
@ -21,8 +21,8 @@ import org.matrix.android.sdk.api.util.JsonDict
|
|||
import org.matrix.android.sdk.internal.auth.data.Availability
|
||||
import org.matrix.android.sdk.internal.auth.data.LoginFlowResponse
|
||||
import org.matrix.android.sdk.internal.auth.data.PasswordLoginParams
|
||||
import org.matrix.android.sdk.internal.auth.data.RiotConfig
|
||||
import org.matrix.android.sdk.internal.auth.data.TokenLoginParams
|
||||
import org.matrix.android.sdk.internal.auth.data.WebClientConfig
|
||||
import org.matrix.android.sdk.internal.auth.login.ResetPasswordMailConfirmed
|
||||
import org.matrix.android.sdk.internal.auth.registration.AddThreePidRegistrationParams
|
||||
import org.matrix.android.sdk.internal.auth.registration.AddThreePidRegistrationResponse
|
||||
|
@ -44,16 +44,16 @@ import retrofit2.http.Url
|
|||
*/
|
||||
internal interface AuthAPI {
|
||||
/**
|
||||
* Get a Riot config file, using the name including the domain
|
||||
* Get a Web client config file, using the name including the domain
|
||||
*/
|
||||
@GET("config.{domain}.json")
|
||||
suspend fun getRiotConfigDomain(@Path("domain") domain: String): RiotConfig
|
||||
suspend fun getWebClientConfigDomain(@Path("domain") domain: String): WebClientConfig
|
||||
|
||||
/**
|
||||
* Get a Riot config file
|
||||
* Get a Web client default config file
|
||||
*/
|
||||
@GET("config.json")
|
||||
suspend fun getRiotConfig(): RiotConfig
|
||||
suspend fun getWebClientConfig(): WebClientConfig
|
||||
|
||||
/**
|
||||
* Get the version information of the homeserver
|
||||
|
|
|
@ -33,7 +33,7 @@ import org.matrix.android.sdk.api.failure.MatrixIdFailure
|
|||
import org.matrix.android.sdk.api.session.Session
|
||||
import org.matrix.android.sdk.api.util.appendParamToUrl
|
||||
import org.matrix.android.sdk.internal.SessionManager
|
||||
import org.matrix.android.sdk.internal.auth.data.RiotConfig
|
||||
import org.matrix.android.sdk.internal.auth.data.WebClientConfig
|
||||
import org.matrix.android.sdk.internal.auth.db.PendingSessionData
|
||||
import org.matrix.android.sdk.internal.auth.login.DefaultLoginWizard
|
||||
import org.matrix.android.sdk.internal.auth.login.DirectLoginTask
|
||||
|
@ -145,7 +145,7 @@ internal class DefaultAuthenticationService @Inject constructor(
|
|||
return result.fold(
|
||||
{
|
||||
// The homeserver exists and up to date, keep the config
|
||||
// Homeserver url may have been changed, if it was a Riot url
|
||||
// Homeserver url may have been changed, if it was a Web client url
|
||||
val alteredHomeServerConnectionConfig = homeServerConnectionConfig.copy(
|
||||
homeServerUriBase = Uri.parse(it.homeServerUrl)
|
||||
)
|
||||
|
@ -191,8 +191,8 @@ internal class DefaultAuthenticationService @Inject constructor(
|
|||
{
|
||||
if (it is Failure.OtherServerError
|
||||
&& it.httpCode == HttpsURLConnection.HTTP_NOT_FOUND /* 404 */) {
|
||||
// It's maybe a Riot url?
|
||||
getRiotDomainLoginFlowInternal(homeServerConnectionConfig)
|
||||
// It's maybe a Web client url?
|
||||
getWebClientDomainLoginFlowInternal(homeServerConnectionConfig)
|
||||
} else {
|
||||
throw it
|
||||
}
|
||||
|
@ -204,20 +204,20 @@ internal class DefaultAuthenticationService @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private suspend fun getRiotDomainLoginFlowInternal(homeServerConnectionConfig: HomeServerConnectionConfig): LoginFlowResult {
|
||||
private suspend fun getWebClientDomainLoginFlowInternal(homeServerConnectionConfig: HomeServerConnectionConfig): LoginFlowResult {
|
||||
val authAPI = buildAuthAPI(homeServerConnectionConfig)
|
||||
|
||||
val domain = homeServerConnectionConfig.homeServerUri.host
|
||||
?: return getRiotLoginFlowInternal(homeServerConnectionConfig)
|
||||
?: return getWebClientLoginFlowInternal(homeServerConnectionConfig)
|
||||
|
||||
// Ok, try to get the config.domain.json file of a RiotWeb client
|
||||
// Ok, try to get the config.domain.json file of a Web client
|
||||
return runCatching {
|
||||
executeRequest(null) {
|
||||
authAPI.getRiotConfigDomain(domain)
|
||||
authAPI.getWebClientConfigDomain(domain)
|
||||
}
|
||||
}
|
||||
.map { riotConfig ->
|
||||
onRiotConfigRetrieved(homeServerConnectionConfig, riotConfig)
|
||||
.map { webClientConfig ->
|
||||
onWebClientConfigRetrieved(homeServerConnectionConfig, webClientConfig)
|
||||
}
|
||||
.fold(
|
||||
{
|
||||
|
@ -227,7 +227,7 @@ internal class DefaultAuthenticationService @Inject constructor(
|
|||
if (it is Failure.OtherServerError
|
||||
&& it.httpCode == HttpsURLConnection.HTTP_NOT_FOUND /* 404 */) {
|
||||
// Try with config.json
|
||||
getRiotLoginFlowInternal(homeServerConnectionConfig)
|
||||
getWebClientLoginFlowInternal(homeServerConnectionConfig)
|
||||
} else {
|
||||
throw it
|
||||
}
|
||||
|
@ -235,20 +235,20 @@ internal class DefaultAuthenticationService @Inject constructor(
|
|||
)
|
||||
}
|
||||
|
||||
private suspend fun getRiotLoginFlowInternal(homeServerConnectionConfig: HomeServerConnectionConfig): LoginFlowResult {
|
||||
private suspend fun getWebClientLoginFlowInternal(homeServerConnectionConfig: HomeServerConnectionConfig): LoginFlowResult {
|
||||
val authAPI = buildAuthAPI(homeServerConnectionConfig)
|
||||
|
||||
// Ok, try to get the config.json file of a RiotWeb client
|
||||
// Ok, try to get the config.json file of a Web client
|
||||
return executeRequest(null) {
|
||||
authAPI.getRiotConfig()
|
||||
authAPI.getWebClientConfig()
|
||||
}
|
||||
.let { riotConfig ->
|
||||
onRiotConfigRetrieved(homeServerConnectionConfig, riotConfig)
|
||||
.let { webClientConfig ->
|
||||
onWebClientConfigRetrieved(homeServerConnectionConfig, webClientConfig)
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun onRiotConfigRetrieved(homeServerConnectionConfig: HomeServerConnectionConfig, riotConfig: RiotConfig): LoginFlowResult {
|
||||
val defaultHomeServerUrl = riotConfig.getPreferredHomeServerUrl()
|
||||
private suspend fun onWebClientConfigRetrieved(homeServerConnectionConfig: HomeServerConnectionConfig, webClientConfig: WebClientConfig): LoginFlowResult {
|
||||
val defaultHomeServerUrl = webClientConfig.getPreferredHomeServerUrl()
|
||||
if (defaultHomeServerUrl?.isNotEmpty() == true) {
|
||||
// Ok, good sign, we got a default hs url
|
||||
val newHomeServerConnectionConfig = homeServerConnectionConfig.copy(
|
||||
|
|
|
@ -20,7 +20,7 @@ import com.squareup.moshi.Json
|
|||
import com.squareup.moshi.JsonClass
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
internal data class RiotConfig(
|
||||
internal data class WebClientConfig(
|
||||
/**
|
||||
* This is now deprecated, but still used first, rather than value from "default_server_config"
|
||||
*/
|
||||
|
@ -28,7 +28,7 @@ internal data class RiotConfig(
|
|||
val defaultHomeServerUrl: String?,
|
||||
|
||||
@Json(name = "default_server_config")
|
||||
val defaultServerConfig: RiotConfigDefaultServerConfig?
|
||||
val defaultServerConfig: WebClientConfigDefaultServerConfig?
|
||||
) {
|
||||
fun getPreferredHomeServerUrl(): String? {
|
||||
return defaultHomeServerUrl
|
||||
|
@ -38,13 +38,13 @@ internal data class RiotConfig(
|
|||
}
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
internal data class RiotConfigDefaultServerConfig(
|
||||
internal data class WebClientConfigDefaultServerConfig(
|
||||
@Json(name = "m.homeserver")
|
||||
val homeServer: RiotConfigBaseConfig? = null
|
||||
val homeServer: WebClientConfigBaseConfig? = null
|
||||
)
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
internal data class RiotConfigBaseConfig(
|
||||
internal data class WebClientConfigBaseConfig(
|
||||
@Json(name = "base_url")
|
||||
val baseURL: String? = null
|
||||
)
|
Loading…
Reference in a new issue