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"
6161
6262You can create a basic configuration in `$CONFIG_DIR/iamb/config.json` that looks like:
6363
64```json
65{
66 "profiles": {
67 "example.com": {
68 "user_id": "@user:example.com"
69 }
70 }
71}
72```
73
74If 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
76you can explicitly specify the homeserver URL to use:
77
6478```json
6579{
6680 "profiles": {
@@ -122,6 +136,7 @@ iamb is released under the [Apache License, Version 2.0].
122136[iamb.chat]: https://iamb.chat
123137[gomuks]: https://github.com/tulir/gomuks
124138[weechat-matrix]: https://github.com/poljar/weechat-matrix
139[well_known_entry]: https://spec.matrix.org/latest/client-server-api/#getwell-knownmatrixclient
125140[#8]: https://github.com/ulyssa/iamb/issues/8
126141[#14]: https://github.com/ulyssa/iamb/issues/14
127142[#16]: https://github.com/ulyssa/iamb/issues/16
src/config.rs +1 −1
@@ -505,7 +505,7 @@ pub enum Layout {
505505#[derive(Clone, Deserialize)]
506506pub struct ProfileConfig {
507507 pub user_id: OwnedUserId,
508 pub url: Url,
508 pub url: Option<Url>,
509509 pub settings: Option<Tunables>,
510510 pub dirs: Option<Directories>,
511511 pub layout: Option<Layout>,
src/tests.rs +1 −1
@@ -209,7 +209,7 @@ pub fn mock_settings() -> ApplicationSettings {
209209 profile_name: "test".into(),
210210 profile: ProfileConfig {
211211 user_id: user_id!("@user:example.com").to_owned(),
212 url: Url::parse("https://example.com").unwrap(),
212 url: None,
213213 settings: None,
214214 dirs: None,
215215 layout: None,
src/worker.rs +12 −6
@@ -738,15 +738,21 @@ impl ClientWorker {
738738 let req_config = RequestConfig::new().timeout(req_timeout).retry_timeout(req_timeout);
739739
740740 // Set up the Matrix client for the selected profile.
741 let client = Client::builder()
741 let builder = Client::builder()
742742 .http_client(Arc::new(http))
743 .homeserver_url(account.url.clone())
744743 .sled_store(settings.matrix_dir.as_path(), None)
745744 .expect("Failed to setup up sled store for Matrix SDK")
746 .request_config(req_config)
747 .build()
748 .await
749 .expect("Failed to instantiate Matrix client");
745 .request_config(req_config);
746
747 let builder = if let Some(url) = account.url.as_ref() {
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");
750756
751757 let mut worker = ClientWorker {
752758 initialized: false,