Skip to content

Commit ffb1302

Browse files
committed
feat: use the raw homeserver URL instead of manually removing the scheme
On the one hand, the SDK knows what to do and will clean up the URL if needs be, guessing what the best scheme (http or https) is based on the prefix. On the other hand, trimming the scheme as done here doesn't allow for manual testing on insecure servers, which is handy in e2e testing situations.
1 parent d784ca3 commit ffb1302

File tree

3 files changed

+3
-8
lines changed

3 files changed

+3
-8
lines changed

changelog.d/1382.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Let the SDK figure the best scheme given an homeserver URL (thus allowing HTTP homeservers)

features/login/impl/src/main/kotlin/io/element/android/features/login/impl/changeserver/ChangeServerPresenter.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,9 @@ import io.element.android.features.login.impl.error.ChangeServerError
2727
import io.element.android.libraries.architecture.Async
2828
import io.element.android.libraries.architecture.Presenter
2929
import io.element.android.libraries.architecture.runCatchingUpdatingState
30-
import io.element.android.libraries.core.data.tryOrNull
3130
import io.element.android.libraries.matrix.api.auth.MatrixAuthenticationService
3231
import kotlinx.coroutines.CoroutineScope
3332
import kotlinx.coroutines.launch
34-
import java.net.URL
3533
import javax.inject.Inject
3634

3735
class ChangeServerPresenter @Inject constructor(
@@ -65,8 +63,7 @@ class ChangeServerPresenter @Inject constructor(
6563
changeServerAction: MutableState<Async<Unit>>,
6664
) = launch {
6765
suspend {
68-
val domain = tryOrNull { URL(data.title) }?.host ?: data.title
69-
authenticationService.setHomeserver(domain).map {
66+
authenticationService.setHomeserver(data.title).map {
7067
authenticationService.getHomeserverDetails().value!!
7168
// Valid, remember user choice
7269
accountProviderDataSource.userSelection(data)

features/login/impl/src/main/kotlin/io/element/android/features/login/impl/screens/confirmaccountprovider/ConfirmAccountProviderPresenter.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,9 @@ import io.element.android.features.login.impl.oidc.customtab.DefaultOidcActionFl
3535
import io.element.android.libraries.architecture.Async
3636
import io.element.android.libraries.architecture.Presenter
3737
import io.element.android.libraries.architecture.runCatchingUpdatingState
38-
import io.element.android.libraries.core.data.tryOrNull
3938
import io.element.android.libraries.matrix.api.auth.MatrixAuthenticationService
4039
import kotlinx.coroutines.CoroutineScope
4140
import kotlinx.coroutines.launch
42-
import java.net.URL
4341

4442
class ConfirmAccountProviderPresenter @AssistedInject constructor(
4543
@Assisted private val params: Params,
@@ -97,8 +95,7 @@ class ConfirmAccountProviderPresenter @AssistedInject constructor(
9795
loginFlowAction: MutableState<Async<LoginFlow>>,
9896
) = launch {
9997
suspend {
100-
val domain = tryOrNull { URL(homeserverUrl) }?.host ?: homeserverUrl
101-
authenticationService.setHomeserver(domain).map {
98+
authenticationService.setHomeserver(homeserverUrl).map {
10299
val matrixHomeServerDetails = authenticationService.getHomeserverDetails().value!!
103100
if (matrixHomeServerDetails.supportsOidcLogin) {
104101
// Retrieve the details right now

0 commit comments

Comments
 (0)