Well-known lookups should not include the port of a server.

This commit is contained in:
Michael Kaye 2022-05-18 15:21:12 +01:00
parent 738ce18a2f
commit 7efd41e17a
2 changed files with 6 additions and 2 deletions

View file

@ -381,7 +381,7 @@ internal class DefaultAuthenticationService @Inject constructor(
return getWellknownTask.execute( return getWellknownTask.execute(
GetWellknownTask.Params( GetWellknownTask.Params(
domain = matrixId.getDomain(), domain = matrixId.getDomain().substringBeforeLast(":"),
homeServerConnectionConfig = homeServerConnectionConfig.orWellKnownDefaults() homeServerConnectionConfig = homeServerConnectionConfig.orWellKnownDefaults()
) )
) )

View file

@ -93,10 +93,14 @@ internal class DefaultGetHomeServerCapabilitiesTask @Inject constructor(
} }
}.getOrNull() }.getOrNull()
// Domain may include a port (eg, matrix.org:8080)
// Per https://spec.matrix.org/latest/client-server-api/#well-known-uri we should extract the hostname from the server name
// So we take everything before the last : as the domain for the well-known task.
// NB: This is not always the same endpoint as capabilities / mediaConfig uses.
val wellknownResult = runCatching { val wellknownResult = runCatching {
getWellknownTask.execute( getWellknownTask.execute(
GetWellknownTask.Params( GetWellknownTask.Params(
domain = userId.getDomain(), domain = userId.getDomain().substringBeforeLast(":"),
homeServerConnectionConfig = homeServerConnectionConfig homeServerConnectionConfig = homeServerConnectionConfig
) )
) )