Commit a411c18fcc

a411c18fcc39f3e88ccb871c90dfb4cc49a6cc74

parent: 2f1a9a65ce

Unregistered key

vaw <git@nlih.de> · 2026-10-01 12:06 UTC
committer: <noreply@github.com>

Use the `via` parameter from space children to find rooms (#765)

Layout: unified · split

src/base.rs +1 −1
@@ -2371,7 +2371,7 @@ pub struct ChatStore {
23712371 /// Cache of encountered `via` parameters in room links.
23722372 ///
23732373 /// This is stored here because this data is lost in the conversion to [IambId].
2374 pub room_via: HashMap<OwnedRoomOrAliasId, Vec<OwnedServerName>>,
2374 pub room_via: HashMap<OwnedRoomOrAliasId, HashSet<OwnedServerName>>,
23752375
23762376 /// Map of joined spaces.
23772377 pub spaces: HashMap<OwnedRoomId, SpaceInfo>,
src/config/mod.rs +7 −2
@@ -1,5 +1,6 @@
11//! # Logic for loading and validating application configuration
22
3use std::collections::HashSet;
34use std::env;
45use std::fs::File;
56use std::io::{BufReader, BufWriter, Write as _};
@@ -802,7 +803,7 @@ pub struct TunableValues {
802803 pub message_user_color: bool,
803804 pub default_register: Option<Register>,
804805 pub default_room: Option<String>,
805 pub default_via: Vec<OwnedServerName>,
806 pub default_via: HashSet<OwnedServerName>,
806807 pub open_command: Option<Vec<String>>,
807808 pub mouse: Mouse,
808809 pub notifications: Notifications,
@@ -965,7 +966,11 @@ impl Tunables {
965966 message_user_color: self.message_user_color.unwrap_or(false),
966967 default_register: self.default_register,
967968 default_room: self.default_room,
968 default_via: self.default_via.unwrap_or_else(|| vec![DEFAULT_VIA_SERVER.clone()]),
969 default_via: self
970 .default_via
971 .unwrap_or_else(|| vec![DEFAULT_VIA_SERVER.clone()])
972 .into_iter()
973 .collect(),
969974 open_command: self.open_command,
970975 mouse: self.mouse.unwrap_or_default(),
971976 notifications: self.notifications.unwrap_or_default(),
src/main.rs +6 −1
@@ -147,7 +147,12 @@ fn resolve_mxid(
147147 },
148148 };
149149
150 store.application.room_via.insert(alias_id.to_owned(), via);
150 store
151 .application
152 .room_via
153 .entry(alias_id.to_owned())
154 .or_default()
155 .extend(via);
151156
152157 Ok(IambId::Room(alias_id, None))
153158}
src/tests.rs +1 −1
@@ -153,7 +153,7 @@ pub fn mock_tunables() -> TunableValues {
153153 ignorecase: false,
154154 default_register: None,
155155 default_room: None,
156 default_via: vec![],
156 default_via: Default::default(),
157157 encryption: Encryption::default().values(),
158158 input_prompt: None,
159159 log_level: "warn".into(),
src/windows/room/not_joined.rs +3 −1
@@ -181,7 +181,9 @@ impl NotJoinedState {
181181 .room_via
182182 .get(self.alias())
183183 .unwrap_or(&store.application.settings.tunables.default_via)
184 .to_vec();
184 .iter()
185 .cloned()
186 .collect();
185187
186188 let chan = store.application.worker.join_room_chan(self.alias().to_owned(), via);
187189 self.joining = Some(chan);
src/worker.rs +15 −3
@@ -271,7 +271,9 @@ async fn run_plan(client: &Client, store: &AsyncProgramStore, plan: Plan) {
271271 .room_via
272272 .get(&alias_id)
273273 .unwrap_or(&locked.application.settings.tunables.default_via)
274 .to_vec()
274 .iter()
275 .cloned()
276 .collect()
275277 };
276278
277279 let res = client.get_room_preview(&alias_id, via).await;
@@ -993,11 +995,15 @@ async fn load_space_children(client: &Client, store: &AsyncProgramStore) {
993995 }
994996
995997 let mut locked = store.lock().await;
998 let ChatStore { spaces, room_via, .. } = &mut locked.application;
999
9961000 for (room, ev) in all_events {
9971001 let room_id = room.room_id().to_owned();
998 let info = locked.application.spaces.entry(room_id).or_default();
1002 let info = spaces.entry(room_id.clone()).or_default();
9991003 match ev {
10001004 SyncStateEvent::Original(ev) => {
1005 room_via.entry(room_id.into()).or_default().extend(ev.content.via.clone());
1006
10011007 info.children.insert(ev.state_key, (ev.content, ev.origin_server_ts));
10021008 },
10031009 SyncStateEvent::Redacted(ev) => {
@@ -1601,10 +1607,16 @@ impl ClientWorker {
16011607 async move {
16021608 let room_id = room.room_id().to_owned();
16031609 let mut locked = store.lock().await;
1610 let ChatStore { spaces, room_via, .. } = &mut locked.application;
16041611
1605 let info = locked.application.spaces.entry(room_id).or_default();
1612 let info = spaces.entry(room_id.clone()).or_default();
16061613 match ev {
16071614 SyncStateEvent::Original(ev) => {
1615 room_via
1616 .entry(room_id.into())
1617 .or_default()
1618 .extend(ev.content.via.clone());
1619
16081620 info.children.insert(ev.state_key, (ev.content, ev.origin_server_ts));
16091621 },
16101622 SyncStateEvent::Redacted(ev) => {