From 7595cab178a790e429fd5562e81ec00436b0247e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Fri, 27 Mar 2020 09:22:29 +0100 Subject: [PATCH] async_client: Allow setting the initial device display name. --- examples/login.rs | 4 +++- src/async_client.rs | 3 ++- tests/async_client_tests.rs | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/login.rs b/examples/login.rs index 0dd83f8b..a623016d 100644 --- a/examples/login.rs +++ b/examples/login.rs @@ -47,7 +47,9 @@ async fn login( client.add_event_callback(async_cb); - client.login(username, password, None).await?; + client + .login(username, password, None, Some("rust-sdk".to_string())) + .await?; client.sync_forever(SyncSettings::new(), |_| async {}).await; Ok(()) diff --git a/src/async_client.rs b/src/async_client.rs index 8c3a4808..89e09390 100644 --- a/src/async_client.rs +++ b/src/async_client.rs @@ -341,6 +341,7 @@ impl AsyncClient { user: S, password: S, device_id: Option, + initial_device_display_name: Option, ) -> Result { info!("Logging in to {} as {:?}", self.homeserver, user); @@ -350,7 +351,7 @@ impl AsyncClient { password: password.into(), }, device_id: device_id.map(|d| d.into()), - initial_device_display_name: None, + initial_device_display_name: initial_device_display_name.map(|d| d.into()), }; let response = self.send(request).await?; diff --git a/tests/async_client_tests.rs b/tests/async_client_tests.rs index 1103310c..f5a972c8 100644 --- a/tests/async_client_tests.rs +++ b/tests/async_client_tests.rs @@ -22,7 +22,7 @@ fn login() { let mut client = AsyncClient::new(homeserver, None).unwrap(); - rt.block_on(client.login("example", "wordpass", None)) + rt.block_on(client.login("example", "wordpass", None, None)) .unwrap(); let logged_in = rt.block_on(client.logged_in());