Commit 84bc6be822
84bc6be8221ebef2e104f18456910a5569c40dac
parent: c5999bffc8
Unregistered key
Ulyssa <git@ulyssa.dev> · 2024-02-29 07:21 UTC
committer: <noreply@github.com>
Support following the .well-known entries for a username's domain (#209)
Layout: unified · split
README.md
+15
| @@ -61,6 +61,20 @@ nix profile install "github:ulyssa/iamb" |
| 61 | |
61 | |
| 62 | You can create a basic configuration in `$CONFIG_DIR/iamb/config.json` that looks like: |
62 | You can create a basic configuration in `$CONFIG_DIR/iamb/config.json` that looks like: |
| 63 | |
63 | |
| |
64 | ```json |
| |
65 | { |
| |
66 | "profiles": { |
| |
67 | "example.com": { |
| |
68 | "user_id": "@user:example.com" |
| |
69 | } |
| |
70 | } |
| |
71 | } |
| |
72 | ``` |
| |
73 | |
| |
74 | If you homeserver is located on a different domain than the server part of the |
| |
75 | `user_id` and you don't have a [`/.well-known`][well_known_entry] entry, then |
| |
76 | you can explicitly specify the homeserver URL to use: |
| |
77 | |
| 64 | ```json |
78 | ```json |
| 65 | { |
79 | { |
| 66 | "profiles": { |
80 | "profiles": { |
| @@ -122,6 +136,7 @@ iamb is released under the [Apache License, Version 2.0]. |
| 122 | [iamb.chat]: https://iamb.chat |
136 | [iamb.chat]: https://iamb.chat |
| 123 | [gomuks]: https://github.com/tulir/gomuks |
137 | [gomuks]: https://github.com/tulir/gomuks |
| 124 | [weechat-matrix]: https://github.com/poljar/weechat-matrix |
138 | [weechat-matrix]: https://github.com/poljar/weechat-matrix |
| |
139 | [well_known_entry]: https://spec.matrix.org/latest/client-server-api/#getwell-knownmatrixclient |
| 125 | [#8]: https://github.com/ulyssa/iamb/issues/8 |
140 | [#8]: https://github.com/ulyssa/iamb/issues/8 |
| 126 | [#14]: https://github.com/ulyssa/iamb/issues/14 |
141 | [#14]: https://github.com/ulyssa/iamb/issues/14 |
| 127 | [#16]: https://github.com/ulyssa/iamb/issues/16 |
142 | [#16]: https://github.com/ulyssa/iamb/issues/16 |
src/config.rs
+1 −1
| @@ -505,7 +505,7 @@ pub enum Layout { |
| 505 | #[derive(Clone, Deserialize)] |
505 | #[derive(Clone, Deserialize)] |
| 506 | pub struct ProfileConfig { |
506 | pub struct ProfileConfig { |
| 507 | pub user_id: OwnedUserId, |
507 | pub user_id: OwnedUserId, |
| 508 | pub url: Url, |
508 | pub url: Option<Url>, |
| 509 | pub settings: Option<Tunables>, |
509 | pub settings: Option<Tunables>, |
| 510 | pub dirs: Option<Directories>, |
510 | pub dirs: Option<Directories>, |
| 511 | pub layout: Option<Layout>, |
511 | pub layout: Option<Layout>, |
src/tests.rs
+1 −1
| @@ -209,7 +209,7 @@ pub fn mock_settings() -> ApplicationSettings { |
| 209 | profile_name: "test".into(), |
209 | profile_name: "test".into(), |
| 210 | profile: ProfileConfig { |
210 | profile: ProfileConfig { |
| 211 | user_id: user_id!("@user:example.com").to_owned(), |
211 | user_id: user_id!("@user:example.com").to_owned(), |
| 212 | url: Url::parse("https://example.com").unwrap(), |
212 | url: None, |
| 213 | settings: None, |
213 | settings: None, |
| 214 | dirs: None, |
214 | dirs: None, |
| 215 | layout: None, |
215 | layout: None, |
src/worker.rs
+12 −6
| @@ -738,15 +738,21 @@ impl ClientWorker { |
| 738 | let req_config = RequestConfig::new().timeout(req_timeout).retry_timeout(req_timeout); |
738 | let req_config = RequestConfig::new().timeout(req_timeout).retry_timeout(req_timeout); |
| 739 | |
739 | |
| 740 | // Set up the Matrix client for the selected profile. |
740 | // Set up the Matrix client for the selected profile. |
| 741 | let client = Client::builder() |
741 | let builder = Client::builder() |
| 742 | .http_client(Arc::new(http)) |
742 | .http_client(Arc::new(http)) |
| 743 | .homeserver_url(account.url.clone()) |
| |
| 744 | .sled_store(settings.matrix_dir.as_path(), None) |
743 | .sled_store(settings.matrix_dir.as_path(), None) |
| 745 | .expect("Failed to setup up sled store for Matrix SDK") |
744 | .expect("Failed to setup up sled store for Matrix SDK") |
| 746 | .request_config(req_config) |
745 | .request_config(req_config); |
| 747 | .build() |
746 | |
| 748 | .await |
747 | let builder = if let Some(url) = account.url.as_ref() { |
| 749 | .expect("Failed to instantiate Matrix client"); |
748 | // Use the explicitly specified homeserver. |
| |
749 | builder.homeserver_url(url.as_str()) |
| |
750 | } else { |
| |
751 | // Try to discover the homeserver from the user ID. |
| |
752 | builder.server_name(account.user_id.server_name()) |
| |
753 | }; |
| |
754 | |
| |
755 | let client = builder.build().await.expect("Failed to instantiate Matrix client"); |
| 750 | |
756 | |
| 751 | let mut worker = ClientWorker { |
757 | let mut worker = ClientWorker { |
| 752 | initialized: false, |
758 | initialized: false, |