Commit e02e5a4787
Unsigned
Layout: unified · split
src/server.rs +22 −3
| @@ -80,8 +80,8 @@ use matrix_sdk::{ | ||
| 80 | 80 | SyncStateEvent, |
| 81 | 81 | }, |
| 82 | 82 | DeviceId, DeviceKeyAlgorithm, MilliSecondsSinceUnixEpoch, |
| 83 | OwnedDeviceId, OwnedMxcUri, OwnedRoomId, OwnedRoomOrAliasId, | |
| 84 | OwnedUserId, RoomId, UserId, | |
| 83 | OwnedDeviceId, OwnedMxcUri, OwnedRoomAliasId, OwnedRoomId, | |
| 84 | OwnedRoomOrAliasId, OwnedServerName, OwnedUserId, RoomId, UserId, | |
| 85 | 85 | }, |
| 86 | 86 | Client, Error, |
| 87 | 87 | }; |
| @@ -235,8 +235,11 @@ impl MatrixServer { | ||
| 235 | 235 | let target = room_id_or_alias.to_string(); |
| 236 | 236 | let result = connection |
| 237 | 237 | .spawn(async move { |
| 238 | let servers = | |
| 239 | resolve_alias_servers(&client, &room_id_or_alias).await; | |
| 240 | ||
| 238 | 241 | client |
| 239 | .join_room_by_id_or_alias(&room_id_or_alias, &[]) | |
| 242 | .join_room_by_id_or_alias(&room_id_or_alias, &servers) | |
| 240 | 243 | .await |
| 241 | 244 | }) |
| 242 | 245 | .await; |
| @@ -479,6 +482,22 @@ fn format_join_error(error: &Error, target: &str) -> String { | ||
| 479 | 482 | } |
| 480 | 483 | } |
| 481 | 484 | |
| 485 | async fn resolve_alias_servers( | |
| 486 | client: &Client, | |
| 487 | room_id_or_alias: &OwnedRoomOrAliasId, | |
| 488 | ) -> Vec<OwnedServerName> { | |
| 489 | let Ok(alias) = room_id_or_alias.as_str().parse::<OwnedRoomAliasId>() | |
| 490 | else { | |
| 491 | return Vec::new(); | |
| 492 | }; | |
| 493 | ||
| 494 | client | |
| 495 | .resolve_room_alias(&alias) | |
| 496 | .await | |
| 497 | .map(|response| response.servers) | |
| 498 | .unwrap_or_default() | |
| 499 | } | |
| 500 | ||
| 482 | 501 | impl Drop for MatrixServer { |
| 483 | 502 | fn drop(&mut self) { |
| 484 | 503 | // TODO close all the server buffers. |