Commit 46f1be6212

46f1be6212645db4b853f77e91bcf756dab7ca8e

parent: 16961a1f6e

Unregistered key

Ulyssa <git@ulyssa.dev> · 2026-09-14 03:30 UTC
committer: <noreply@github.com>

Add `default_via` to always tell homeserver how to resolve a room (#694)

Layout: unified · split

Cargo.toml +1 −1
@@ -46,6 +46,7 @@ html5ever = "0.39.0"
4646http-serde = "2.1.1"
4747humansize = "2.0.0"
4848image = {version = "0.25.6", features = ["serde"], default-features = false}
49lazy_static = "1.4.0"
4950libc = "0.2"
5051linkify = "0.11.0"
5152markup5ever_rcdom = "0.39"
@@ -112,7 +113,6 @@ default-features = false
112113features = ["serde", "crossterm", "image-defaults"]
113114
114115[dev-dependencies]
115lazy_static = "1.4.0"
116116pretty_assertions = "1.4.0"
117117
118118[profile.release-lto]
docs/iamb.5 +4
@@ -160,6 +160,10 @@ Possible values are
160160.Dq Sy horizontal
161161(the default) and
162162.Dq Sy vertical .
163.It Sy default_via
164The servers to use to join a room if the homeserver cannot figure out how to join it.
165This defaults to
166.Sy ["matrix.org"] .
163167.It Sy encryption
164168Configuration subsection for specific settings related to room encryption.
165169See
src/config.rs +10 −1
@@ -8,11 +8,12 @@ use std::io::{BufReader, BufWriter, Write as _};
88use std::process;
99
1010use clap::Parser;
11use lazy_static::lazy_static;
1112use matrix_sdk::EncryptionState;
1213use matrix_sdk::authentication::matrix::MatrixSession;
1314use matrix_sdk::media::MediaRetentionPolicy;
1415use matrix_sdk::reqwest::header::{HeaderMap, HeaderValue};
15use matrix_sdk::ruma::OwnedDeviceId;
16use matrix_sdk::ruma::{OwnedDeviceId, owned_server_name};
1617use modalkit::crossterm;
1718use modalkit::env::vim::VimMode;
1819use modalkit::keybindings::InputKey;
@@ -34,6 +35,10 @@ macro_rules! usage {
3435 }
3536}
3637
38lazy_static! {
39 pub static ref DEFAULT_VIA_SERVER: OwnedServerName = owned_server_name!("matrix.org");
40}
41
3742const DEFAULT_MEMBERS_SORT: [SortColumn<SortFieldUser>; 4] = [
3843 SortColumn(SortFieldUser::PowerLevel, SortOrder::Ascending),
3944 SortColumn(SortFieldUser::Knock, SortOrder::Ascending),
@@ -855,6 +860,7 @@ pub struct TunableValues {
855860 pub message_user_color: bool,
856861 pub default_register: Option<Register>,
857862 pub default_room: Option<String>,
863 pub default_via: Vec<OwnedServerName>,
858864 pub open_command: Option<Vec<String>>,
859865 pub mouse: Mouse,
860866 pub notifications: Notifications,
@@ -910,6 +916,7 @@ pub struct Tunables {
910916 #[serde(default, deserialize_with = "deserialize_register")]
911917 pub default_register: Option<Register>,
912918 pub default_room: Option<String>,
919 pub default_via: Option<Vec<OwnedServerName>>,
913920 pub open_command: Option<Vec<String>>,
914921 pub mouse: Option<Mouse>,
915922 pub notifications: Option<Notifications>,
@@ -960,6 +967,7 @@ impl Tunables {
960967 message_user_color: self.message_user_color.or(other.message_user_color),
961968 default_register: self.default_register.or(other.default_register),
962969 default_room: self.default_room.or(other.default_room),
970 default_via: self.default_via.or(other.default_via),
963971 open_command: self.open_command.or(other.open_command),
964972 mouse: self.mouse.or(other.mouse),
965973 notifications: self.notifications.or(other.notifications),
@@ -1004,6 +1012,7 @@ impl Tunables {
10041012 message_user_color: self.message_user_color.unwrap_or(false),
10051013 default_register: self.default_register,
10061014 default_room: self.default_room,
1015 default_via: self.default_via.unwrap_or_else(|| vec![DEFAULT_VIA_SERVER.clone()]),
10071016 open_command: self.open_command,
10081017 mouse: self.mouse.unwrap_or_default(),
10091018 notifications: self.notifications.unwrap_or_default(),
src/main.rs +4 −3
@@ -81,16 +81,17 @@ fn config_tab_to_desc(
8181) -> IambResult<WindowLayoutDescription<IambInfo>> {
8282 let desc = match layout {
8383 config::WindowLayout::Window { window } => {
84 let ChatStore { names, worker, .. } = &mut store.application;
84 let ChatStore { names, worker, settings, .. } = &mut store.application;
85 let via = settings.tunables.default_via.clone();
8586
8687 let window = match window {
8788 config::WindowPath::UserId(user_id) => {
88 let room_id = worker.join_room(user_id.to_string(), vec![])?;
89 let room_id = worker.join_room(user_id.to_string(), via)?;
8990 IambId::Room(room_id, None)
9091 },
9192 config::WindowPath::RoomId(room_id) => IambId::Room(room_id, None),
9293 config::WindowPath::AliasId(alias) => {
93 let room_id = worker.join_room(alias.to_string(), vec![])?;
94 let room_id = worker.join_room(alias.to_string(), via)?;
9495 names.insert(alias, room_id.clone());
9596 IambId::Room(room_id, None)
9697 },
src/prelude.rs +1
@@ -30,6 +30,7 @@ pub use matrix_sdk::ruma::{
3030 OwnedRoomAliasId,
3131 OwnedRoomId,
3232 OwnedRoomOrAliasId,
33 OwnedServerName,
3334 OwnedUserId,
3435 RoomId,
3536 UserId,
src/tests.rs +1
@@ -157,6 +157,7 @@ pub fn mock_tunables() -> TunableValues {
157157 ignorecase: false,
158158 default_register: None,
159159 default_room: None,
160 default_via: vec![],
160161 encryption: Encryption::default().values(),
161162 input_prompt: None,
162163 log_level: "warn".into(),
src/windows/mod.rs +3 −2
@@ -905,14 +905,15 @@ impl Window<IambInfo> for IambWindow {
905905 }
906906
907907 fn find(name: String, store: &mut ProgramStore) -> IambResult<Self> {
908 let ChatStore { names, worker, .. } = &mut store.application;
908 let ChatStore { names, worker, settings, .. } = &mut store.application;
909909
910910 if let Some(room) = names.get_mut(&name) {
911911 let id = IambId::Room(room.clone(), None);
912912
913913 IambWindow::open(id, store)
914914 } else {
915 let room_id = worker.join_room(name.clone(), vec![])?;
915 let via = settings.tunables.default_via.clone();
916 let room_id = worker.join_room(name.clone(), via)?;
916917
917918 if let Ok(alias) = OwnedRoomAliasId::from_str(&name) {
918919 names.insert(alias, room_id.clone());