tchapgouv / tchap-android

A matrix client for Android.
https://play.google.com/store/apps/details?id=fr.gouv.tchap.a
Apache License 2.0
19 stars 7 forks source link

Problème d'invitation : IdentityServerUrl comporte un "/" terminal en fin d'URL qui pose problème #949

Closed NicolasBuquet closed 10 months ago

NicolasBuquet commented 12 months ago

Lors de la procédure de création de compte Tchap, l'identityServerUrl peut être renseigné de diverses manières (notamment par un système de fichiers de configuration .well-known surle serveur, actuellement absent).

Une autre manière, celle utilisée actuellement dans l'application Android, est que l'application elle-même construit cette URL.

Sur Android cette construction est déclenchée par les appels suivants :

 homeServerConnectionConfigFactory.create(action.homeServerUrl, fingerprints)

qui appelle

    HomeServerConnectionConfig.Builder().withHomeServerUri(url)

qui appelle à son tour

    fun withHomeServerUri(hsUriString: String): Builder {
            return withHomeServerUri(Uri.parse(hsUriString))
        }

Et donc enfin :

        fun withHomeServerUri(hsUri: Uri): Builder {
            if (hsUri.scheme != "http" && hsUri.scheme != "https") {
                throw RuntimeException("Invalid homeserver URI: $hsUri")
            }
            // ensure trailing /
            val hsString = hsUri.toString().ensureTrailingSlash()
            homeServerUri = try {
                Uri.parse(hsString)
            } catch (e: Exception) {
                throw RuntimeException("Invalid homeserver URI: $hsUri")
            }
            return this
        }

Lors de l'appel initial, action.homeServerUrl ne se termine pas par un "/".

Le "/" terminal est ajouté par la ligne val hsString = hsUri.toString().ensureTrailingSlash().

Ce "/" final pose problème lors de l'invitation par email. Le "/" final provoque un retour d'erreur 500 de la part du back-end.

Ce qui a motivé ce ticket : #856

Il faut supprimer la modification du ticket #856 et enlever cet ajout de "/" final et vérifier le bon comportement du reste de l'application ensuite.