mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-09 08:27:32 -04:00
feat(bindings): upload user avatar
This commit is contained in:
committed by
Benjamin Bouvier
parent
d7f5cd51e4
commit
fa91a74452
@@ -33,6 +33,7 @@ use matrix_sdk::{
|
||||
AuthApi, AuthSession, Client as MatrixClient, SessionChange,
|
||||
};
|
||||
use matrix_sdk_ui::notification_client::NotificationProcessSetup as MatrixNotificationProcessSetup;
|
||||
use mime::Mime;
|
||||
use ruma::{
|
||||
api::client::discovery::discover_homeserver::AuthenticationServerInfo,
|
||||
push::{HttpPusherData as RumaHttpPusherData, PushFormat as RumaPushFormat},
|
||||
@@ -458,6 +459,15 @@ impl Client {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn upload_avatar(&self, mime_type: String, data: Vec<u8>) -> Result<(), ClientError> {
|
||||
let client = self.inner.clone();
|
||||
RUNTIME.block_on(async move {
|
||||
let mime: Mime = mime_type.parse()?;
|
||||
client.account().upload_avatar(&mime, data).await?;
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
pub fn avatar_url(&self) -> Result<Option<String>, ClientError> {
|
||||
let l = self.inner.clone();
|
||||
RUNTIME.block_on(async move {
|
||||
|
||||
Reference in New Issue
Block a user