Skip to content

Commit

Permalink
fix(sdk): Don't confuse server and homeserver.
Browse files Browse the repository at this point in the history
This patch fixes an error where the `homeserver` is used for the
`server` value.
  • Loading branch information
Hywan committed Sep 2, 2024
1 parent 084cfb3 commit b073f28
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions crates/matrix-sdk/src/client/builder/homeserver_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,7 @@ impl HomeserverConfig {
)
.await?;

HomeserverDiscoveryResult {
server: Some(server),
homeserver,
well_known,
supported_versions,
}
HomeserverDiscoveryResult { server, homeserver, well_known, supported_versions }
}
})
}
Expand All @@ -111,7 +106,12 @@ async fn discover_homeserver_from_server_name_or_url(
mut server_name_or_url: String,
http_client: &HttpClient,
) -> Result<
(Url, Url, Option<discover_homeserver::Response>, Option<get_supported_versions::Response>),
(
Option<Url>,
Url,
Option<discover_homeserver::Response>,
Option<get_supported_versions::Response>,
),
ClientBuildError,
> {
let mut discovery_error: Option<ClientBuildError> = None;
Expand All @@ -129,7 +129,7 @@ async fn discover_homeserver_from_server_name_or_url(
match discover_homeserver(server_name, &protocol, http_client).await {
Ok((server, well_known)) => {
return Ok((
server,
Some(server),
Url::parse(&well_known.homeserver.base_url)?,
Some(well_known),
None,
Expand All @@ -154,7 +154,7 @@ async fn discover_homeserver_from_server_name_or_url(
// Make sure the URL is definitely for a homeserver.
match get_supported_versions(&homeserver_url, http_client).await {
Ok(response) => {
return Ok((homeserver_url.clone(), homeserver_url, None, Some(response)));
return Ok((None, homeserver_url, None, Some(response)));
}
Err(e) => {
debug!(error = %e, "Checking supported versions failed.");
Expand Down Expand Up @@ -325,7 +325,7 @@ mod tests {
.await
.unwrap();

assert_eq!(result.server, Some(Url::parse(&homeserver.uri()).unwrap()));
assert!(result.server.is_none());
assert_eq!(result.homeserver, Url::parse(&homeserver.uri()).unwrap());
assert!(result.well_known.is_none());
assert!(result.supported_versions.is_some());
Expand Down

0 comments on commit b073f28

Please sign in to comment.