diff --git a/bindings/matrix-sdk-ffi/src/client.rs b/bindings/matrix-sdk-ffi/src/client.rs index 54406134ef0..06456de64ec 100644 --- a/bindings/matrix-sdk-ffi/src/client.rs +++ b/bindings/matrix-sdk-ffi/src/client.rs @@ -662,7 +662,7 @@ impl Client { pub fn get_profile(&self, user_id: String) -> Result { RUNTIME.block_on(async move { let owned_user_id = UserId::parse(user_id.clone())?; - let response = self.inner.get_profile(&owned_user_id).await?; + let response = self.inner.account().fetch_user_profile_of(&owned_user_id).await?; let user_profile = UserProfile { user_id, diff --git a/crates/matrix-sdk/CHANGELOG.md b/crates/matrix-sdk/CHANGELOG.md index 9cfe0a78819..25fe72860e1 100644 --- a/crates/matrix-sdk/CHANGELOG.md +++ b/crates/matrix-sdk/CHANGELOG.md @@ -10,6 +10,7 @@ Breaking changes: - Replace `impl MediaEventContent` with `&impl MediaEventContent` in `Media::get_file`/`Media::remove_file`/`Media::get_thumbnail`/`Media::remove_thumbnail` - A custom sliding sync proxy set with `ClientBuilder::sliding_sync_proxy` now takes precedence over a discovered proxy. +- `Client::get_profile` was moved to `Account` and renamed to `Account::fetch_user_profile_of`. `Account::get_profile` was renamed to `Account::fetch_user_profile`. Additions: diff --git a/crates/matrix-sdk/src/account.rs b/crates/matrix-sdk/src/account.rs index e2d5ea45ff5..4df13fedd05 100644 --- a/crates/matrix-sdk/src/account.rs +++ b/crates/matrix-sdk/src/account.rs @@ -261,18 +261,29 @@ impl Account { /// # async { /// # let homeserver = Url::parse("http://localhost:8080")?; /// # let client = Client::new(homeserver).await?; - /// let profile = client.account().get_profile().await?; + /// let profile = client.account().fetch_user_profile().await?; /// println!( /// "You are '{:?}' with avatar '{:?}'", /// profile.displayname, profile.avatar_url /// ); /// # anyhow::Ok(()) }; /// ``` - pub async fn get_profile(&self) -> Result { + pub async fn fetch_user_profile(&self) -> Result { let user_id = self.client.user_id().ok_or(Error::AuthenticationRequired)?; + self.fetch_user_profile_of(user_id).await + } + + /// Get the profile for a given user id + /// + /// # Arguments + /// + /// * `user_id` the matrix id this function downloads the profile for + pub async fn fetch_user_profile_of( + &self, + user_id: &UserId, + ) -> Result { let request = get_profile::v3::Request::new(user_id.to_owned()); - let request_config = self.client.request_config().force_auth(); - Ok(self.client.send(request, Some(request_config)).await?) + Ok(self.client.send(request, Some(RequestConfig::short_retry().force_auth())).await?) } /// Change the password of the account. diff --git a/crates/matrix-sdk/src/client/mod.rs b/crates/matrix-sdk/src/client/mod.rs index 1d81a20e1b7..2242ced17af 100644 --- a/crates/matrix-sdk/src/client/mod.rs +++ b/crates/matrix-sdk/src/client/mod.rs @@ -48,7 +48,6 @@ use ruma::{ }, filter::{create_filter::v3::Request as FilterUploadRequest, FilterDefinition}, membership::{join_room_by_id, join_room_by_id_or_alias}, - profile::get_profile, push::{set_pusher, Pusher}, room::create_room, session::login::v3::DiscoveryInfo, @@ -2048,16 +2047,6 @@ impl Client { self.send(request, None).await } - /// Get the profile for a given user id - /// - /// # Arguments - /// - /// * `user_id` the matrix id this function downloads the profile for - pub async fn get_profile(&self, user_id: &UserId) -> Result { - let request = get_profile::v3::Request::new(user_id.to_owned()); - Ok(self.send(request, Some(RequestConfig::short_retry())).await?) - } - /// Get the notification settings of the current owner of the client. pub async fn notification_settings(&self) -> NotificationSettings { let ruleset = self.account().push_rules().await.unwrap_or_else(|_| Ruleset::new()); diff --git a/crates/matrix-sdk/src/widget/settings/mod.rs b/crates/matrix-sdk/src/widget/settings/mod.rs index 2545a49ce30..341de9b0fbb 100644 --- a/crates/matrix-sdk/src/widget/settings/mod.rs +++ b/crates/matrix-sdk/src/widget/settings/mod.rs @@ -91,7 +91,7 @@ impl WidgetSettings { props: ClientProperties, ) -> Result { self._generate_webview_url( - room.client().account().get_profile().await.unwrap_or_default(), + room.client().account().fetch_user_profile().await.unwrap_or_default(), room.own_user_id(), room.room_id(), room.client().device_id().unwrap_or("UNKNOWN".into()),