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