Improve API of interface WellknownRetriever to be able to distinguish between 404 and other errors.

This commit is contained in:
Benoit Marty 2025-10-22 14:13:36 +02:00
parent 3f41108db6
commit b45fb2128b
14 changed files with 196 additions and 96 deletions

View file

@ -41,7 +41,7 @@ class DefaultAccountProviderAccessControl(
// Ensure that Element Pro is not required for this account provider
val wellKnown = wellknownRetriever.getElementWellKnown(
baseUrl = accountProviderUrl.ensureProtocol(),
)
).dataOrNull()
if (wellKnown?.enforceElementPro == true) {
throw AccountProviderAccessException.NeedElementProException(
unauthorisedAccountProviderTitle = title,

View file

@ -46,7 +46,7 @@ class HomeserverResolver(
wellknownRetriever.getWellKnown(url)
}
}
val isValid = wellKnown?.isValid().orFalse()
val isValid = wellKnown?.dataOrNull()?.isValid().orFalse()
if (isValid) {
// Emit the list as soon as possible
currentList.add(

View file

@ -30,7 +30,7 @@ class DefaultWebClientUrlForAuthenticationRetriever(
Timber.w("Temporary account creation flow is only supported on matrix.org")
throw AccountCreationNotSupported()
}
val wellknown = wellknownRetriever.getElementWellKnown(homeServerUrl)
val wellknown = wellknownRetriever.getElementWellKnown(homeServerUrl).dataOrNull()
?: throw AccountCreationNotSupported()
val registrationHelperUrl = wellknown.registrationHelperUrl
return if (registrationHelperUrl != null) {