Commit 46f1be6212
Unregistered key
Layout: unified · split
Cargo.toml +1 −1
| @@ -46,6 +46,7 @@ html5ever = "0.39.0" | |||
| 46 | http-serde = "2.1.1" | 46 | http-serde = "2.1.1" |
| 47 | humansize = "2.0.0" | 47 | humansize = "2.0.0" |
| 48 | image = {version = "0.25.6", features = ["serde"], default-features = false} | 48 | image = {version = "0.25.6", features = ["serde"], default-features = false} |
| 49 | lazy_static = "1.4.0" | ||
| 49 | libc = "0.2" | 50 | libc = "0.2" |
| 50 | linkify = "0.11.0" | 51 | linkify = "0.11.0" |
| 51 | markup5ever_rcdom = "0.39" | 52 | markup5ever_rcdom = "0.39" |
| @@ -112,7 +113,6 @@ default-features = false | |||
| 112 | features = ["serde", "crossterm", "image-defaults"] | 113 | features = ["serde", "crossterm", "image-defaults"] |
| 113 | 114 | ||
| 114 | [dev-dependencies] | 115 | [dev-dependencies] |
| 115 | lazy_static = "1.4.0" | ||
| 116 | pretty_assertions = "1.4.0" | 116 | pretty_assertions = "1.4.0" |
| 117 | 117 | ||
| 118 | [profile.release-lto] | 118 | [profile.release-lto] |
docs/iamb.5 +4
| @@ -160,6 +160,10 @@ Possible values are | |||
| 160 | .Dq Sy horizontal | 160 | .Dq Sy horizontal |
| 161 | (the default) and | 161 | (the default) and |
| 162 | .Dq Sy vertical . | 162 | .Dq Sy vertical . |
| 163 | .It Sy default_via | ||
| 164 | The servers to use to join a room if the homeserver cannot figure out how to join it. | ||
| 165 | This defaults to | ||
| 166 | .Sy ["matrix.org"] . | ||
| 163 | .It Sy encryption | 167 | .It Sy encryption |
| 164 | Configuration subsection for specific settings related to room encryption. | 168 | Configuration subsection for specific settings related to room encryption. |
| 165 | See | 169 | See |
src/config.rs +10 −1
| @@ -8,11 +8,12 @@ use std::io::{BufReader, BufWriter, Write as _}; | |||
| 8 | use std::process; | 8 | use std::process; |
| 9 | 9 | ||
| 10 | use clap::Parser; | 10 | use clap::Parser; |
| 11 | use lazy_static::lazy_static; | ||
| 11 | use matrix_sdk::EncryptionState; | 12 | use matrix_sdk::EncryptionState; |
| 12 | use matrix_sdk::authentication::matrix::MatrixSession; | 13 | use matrix_sdk::authentication::matrix::MatrixSession; |
| 13 | use matrix_sdk::media::MediaRetentionPolicy; | 14 | use matrix_sdk::media::MediaRetentionPolicy; |
| 14 | use matrix_sdk::reqwest::header::{HeaderMap, HeaderValue}; | 15 | use matrix_sdk::reqwest::header::{HeaderMap, HeaderValue}; |
| 15 | use matrix_sdk::ruma::OwnedDeviceId; | 16 | use matrix_sdk::ruma::{OwnedDeviceId, owned_server_name}; |
| 16 | use modalkit::crossterm; | 17 | use modalkit::crossterm; |
| 17 | use modalkit::env::vim::VimMode; | 18 | use modalkit::env::vim::VimMode; |
| 18 | use modalkit::keybindings::InputKey; | 19 | use modalkit::keybindings::InputKey; |
| @@ -34,6 +35,10 @@ macro_rules! usage { | |||
| 34 | } | 35 | } |
| 35 | } | 36 | } |
| 36 | 37 | ||
| 38 | lazy_static! { | ||
| 39 | pub static ref DEFAULT_VIA_SERVER: OwnedServerName = owned_server_name!("matrix.org"); | ||
| 40 | } | ||
| 41 | |||
| 37 | const DEFAULT_MEMBERS_SORT: [SortColumn<SortFieldUser>; 4] = [ | 42 | const DEFAULT_MEMBERS_SORT: [SortColumn<SortFieldUser>; 4] = [ |
| 38 | SortColumn(SortFieldUser::PowerLevel, SortOrder::Ascending), | 43 | SortColumn(SortFieldUser::PowerLevel, SortOrder::Ascending), |
| 39 | SortColumn(SortFieldUser::Knock, SortOrder::Ascending), | 44 | SortColumn(SortFieldUser::Knock, SortOrder::Ascending), |
| @@ -855,6 +860,7 @@ pub struct TunableValues { | |||
| 855 | pub message_user_color: bool, | 860 | pub message_user_color: bool, |
| 856 | pub default_register: Option<Register>, | 861 | pub default_register: Option<Register>, |
| 857 | pub default_room: Option<String>, | 862 | pub default_room: Option<String>, |
| 863 | pub default_via: Vec<OwnedServerName>, | ||
| 858 | pub open_command: Option<Vec<String>>, | 864 | pub open_command: Option<Vec<String>>, |
| 859 | pub mouse: Mouse, | 865 | pub mouse: Mouse, |
| 860 | pub notifications: Notifications, | 866 | pub notifications: Notifications, |
| @@ -910,6 +916,7 @@ pub struct Tunables { | |||
| 910 | #[serde(default, deserialize_with = "deserialize_register")] | 916 | #[serde(default, deserialize_with = "deserialize_register")] |
| 911 | pub default_register: Option<Register>, | 917 | pub default_register: Option<Register>, |
| 912 | pub default_room: Option<String>, | 918 | pub default_room: Option<String>, |
| 919 | pub default_via: Option<Vec<OwnedServerName>>, | ||
| 913 | pub open_command: Option<Vec<String>>, | 920 | pub open_command: Option<Vec<String>>, |
| 914 | pub mouse: Option<Mouse>, | 921 | pub mouse: Option<Mouse>, |
| 915 | pub notifications: Option<Notifications>, | 922 | pub notifications: Option<Notifications>, |
| @@ -960,6 +967,7 @@ impl Tunables { | |||
| 960 | message_user_color: self.message_user_color.or(other.message_user_color), | 967 | message_user_color: self.message_user_color.or(other.message_user_color), |
| 961 | default_register: self.default_register.or(other.default_register), | 968 | default_register: self.default_register.or(other.default_register), |
| 962 | default_room: self.default_room.or(other.default_room), | 969 | default_room: self.default_room.or(other.default_room), |
| 970 | default_via: self.default_via.or(other.default_via), | ||
| 963 | open_command: self.open_command.or(other.open_command), | 971 | open_command: self.open_command.or(other.open_command), |
| 964 | mouse: self.mouse.or(other.mouse), | 972 | mouse: self.mouse.or(other.mouse), |
| 965 | notifications: self.notifications.or(other.notifications), | 973 | notifications: self.notifications.or(other.notifications), |
| @@ -1004,6 +1012,7 @@ impl Tunables { | |||
| 1004 | message_user_color: self.message_user_color.unwrap_or(false), | 1012 | message_user_color: self.message_user_color.unwrap_or(false), |
| 1005 | default_register: self.default_register, | 1013 | default_register: self.default_register, |
| 1006 | default_room: self.default_room, | 1014 | default_room: self.default_room, |
| 1015 | default_via: self.default_via.unwrap_or_else(|| vec![DEFAULT_VIA_SERVER.clone()]), | ||
| 1007 | open_command: self.open_command, | 1016 | open_command: self.open_command, |
| 1008 | mouse: self.mouse.unwrap_or_default(), | 1017 | mouse: self.mouse.unwrap_or_default(), |
| 1009 | notifications: self.notifications.unwrap_or_default(), | 1018 | notifications: self.notifications.unwrap_or_default(), |
src/main.rs +4 −3
| @@ -81,16 +81,17 @@ fn config_tab_to_desc( | |||
| 81 | ) -> IambResult<WindowLayoutDescription<IambInfo>> { | 81 | ) -> IambResult<WindowLayoutDescription<IambInfo>> { |
| 82 | let desc = match layout { | 82 | let desc = match layout { |
| 83 | config::WindowLayout::Window { window } => { | 83 | 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(); | ||
| 85 | 86 | ||
| 86 | let window = match window { | 87 | let window = match window { |
| 87 | config::WindowPath::UserId(user_id) => { | 88 | 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)?; |
| 89 | IambId::Room(room_id, None) | 90 | IambId::Room(room_id, None) |
| 90 | }, | 91 | }, |
| 91 | config::WindowPath::RoomId(room_id) => IambId::Room(room_id, None), | 92 | config::WindowPath::RoomId(room_id) => IambId::Room(room_id, None), |
| 92 | config::WindowPath::AliasId(alias) => { | 93 | 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)?; |
| 94 | names.insert(alias, room_id.clone()); | 95 | names.insert(alias, room_id.clone()); |
| 95 | IambId::Room(room_id, None) | 96 | IambId::Room(room_id, None) |
| 96 | }, | 97 | }, |
src/prelude.rs +1
| @@ -30,6 +30,7 @@ pub use matrix_sdk::ruma::{ | |||
| 30 | OwnedRoomAliasId, | 30 | OwnedRoomAliasId, |
| 31 | OwnedRoomId, | 31 | OwnedRoomId, |
| 32 | OwnedRoomOrAliasId, | 32 | OwnedRoomOrAliasId, |
| 33 | OwnedServerName, | ||
| 33 | OwnedUserId, | 34 | OwnedUserId, |
| 34 | RoomId, | 35 | RoomId, |
| 35 | UserId, | 36 | UserId, |
src/tests.rs +1
| @@ -157,6 +157,7 @@ pub fn mock_tunables() -> TunableValues { | |||
| 157 | ignorecase: false, | 157 | ignorecase: false, |
| 158 | default_register: None, | 158 | default_register: None, |
| 159 | default_room: None, | 159 | default_room: None, |
| 160 | default_via: vec![], | ||
| 160 | encryption: Encryption::default().values(), | 161 | encryption: Encryption::default().values(), |
| 161 | input_prompt: None, | 162 | input_prompt: None, |
| 162 | log_level: "warn".into(), | 163 | log_level: "warn".into(), |
src/windows/mod.rs +3 −2
| @@ -905,14 +905,15 @@ impl Window<IambInfo> for IambWindow { | |||
| 905 | } | 905 | } |
| 906 | 906 | ||
| 907 | fn find(name: String, store: &mut ProgramStore) -> IambResult<Self> { | 907 | 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; |
| 909 | 909 | ||
| 910 | if let Some(room) = names.get_mut(&name) { | 910 | if let Some(room) = names.get_mut(&name) { |
| 911 | let id = IambId::Room(room.clone(), None); | 911 | let id = IambId::Room(room.clone(), None); |
| 912 | 912 | ||
| 913 | IambWindow::open(id, store) | 913 | IambWindow::open(id, store) |
| 914 | } else { | 914 | } 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)?; | ||
| 916 | 917 | ||
| 917 | if let Ok(alias) = OwnedRoomAliasId::from_str(&name) { | 918 | if let Ok(alias) = OwnedRoomAliasId::from_str(&name) { |
| 918 | names.insert(alias, room_id.clone()); | 919 | names.insert(alias, room_id.clone()); |