Commit e02e5a4787

e02e5a478781a704a5cad58aa3a3693f8dd4729a

parent: a304b0834a

Unsigned

Darafei Praliaskouski <me@komzpa.net> · 2026-06-30 15:18 UTC
committer: <strk@kbt.io>

fix: pass alias servers to room joins

Layout: unified · split

src/server.rs +22 −3
@@ -80,8 +80,8 @@ use matrix_sdk::{
80 SyncStateEvent, 80 SyncStateEvent,
81 }, 81 },
82 DeviceId, DeviceKeyAlgorithm, MilliSecondsSinceUnixEpoch, 82 DeviceId, DeviceKeyAlgorithm, MilliSecondsSinceUnixEpoch,
83 OwnedDeviceId, OwnedMxcUri, OwnedRoomId, OwnedRoomOrAliasId, 83 OwnedDeviceId, OwnedMxcUri, OwnedRoomAliasId, OwnedRoomId,
84 OwnedUserId, RoomId, UserId, 84 OwnedRoomOrAliasId, OwnedServerName, OwnedUserId, RoomId, UserId,
85 }, 85 },
86 Client, Error, 86 Client, Error,
87}; 87};
@@ -235,8 +235,11 @@ impl MatrixServer {
235 let target = room_id_or_alias.to_string(); 235 let target = room_id_or_alias.to_string();
236 let result = connection 236 let result = connection
237 .spawn(async move { 237 .spawn(async move {
238 let servers =
239 resolve_alias_servers(&client, &room_id_or_alias).await;
240
238 client 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 .await 243 .await
241 }) 244 })
242 .await; 245 .await;
@@ -479,6 +482,22 @@ fn format_join_error(error: &Error, target: &str) -> String {
479 } 482 }
480} 483}
481 484
485async 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
482impl Drop for MatrixServer { 501impl Drop for MatrixServer {
483 fn drop(&mut self) { 502 fn drop(&mut self) {
484 // TODO close all the server buffers. 503 // TODO close all the server buffers.