diff options
Diffstat (limited to '')
| -rw-r--r-- | filamento/src/lib.rs | 9 | ||||
| -rw-r--r-- | filamento/src/logic/online.rs | 7 | 
2 files changed, 13 insertions, 3 deletions
diff --git a/filamento/src/lib.rs b/filamento/src/lib.rs index 42646be..7946241 100644 --- a/filamento/src/lib.rs +++ b/filamento/src/lib.rs @@ -191,6 +191,15 @@ pub struct Client<Fs: FileStore> {      timeout: Duration,  } +impl<Fs: FileStore> Client<Fs> { +    pub fn with_timeout(&self, timeout: Duration) -> Self { +        Self { +            sender: self.sender.clone(), +            timeout, +        } +    } +} +  impl<Fs: FileStore> Clone for Client<Fs> {      fn clone(&self) -> Self {          Self { diff --git a/filamento/src/logic/online.rs b/filamento/src/logic/online.rs index 5b57f84..d9441d7 100644 --- a/filamento/src/logic/online.rs +++ b/filamento/src/logic/online.rs @@ -1,4 +1,4 @@ -use std::io::Cursor; +use std::{io::Cursor, time::Duration};  use base64::{prelude::BASE64_STANDARD, Engine};  use chrono::Utc; @@ -897,7 +897,8 @@ pub async fn handle_change_avatar<Fs: FileStore + Clone>(logic: &ClientLogic<Fs>              // convert the image to png;              let mut data_png = Vec::new(); -            image.write_to(&mut Cursor::new(&mut data_png), image::ImageFormat::Png)?; +            let image = image.resize(192, 192, image::imageops::FilterType::Nearest); +            image.write_to(&mut Cursor::new(&mut data_png), image::ImageFormat::Jpeg)?;              // calculate the length of the data in bytes.              let bytes = data_png.len().try_into()?; @@ -915,7 +916,7 @@ pub async fn handle_change_avatar<Fs: FileStore + Clone>(logic: &ClientLogic<Fs>              logic.client().publish(pep::Item::AvatarData(Some(avatar::Data { hash: hash.clone(), data_b64 })), "urn:xmpp:avatar:data".to_string()).await?;              // publish the metadata to the metadata node -            logic.client().publish(pep::Item::AvatarMetadata(Some(avatar::Metadata { bytes, hash: hash.clone(), r#type: "image/png".to_string() })), "urn:xmpp:avatar:metadata".to_string()).await?; +            logic.client().publish(pep::Item::AvatarMetadata(Some(avatar::Metadata { bytes, hash: hash.clone(), r#type: "image/jpeg".to_string() })), "urn:xmpp:avatar:metadata".to_string()).await?;              // if everything went well, save the data to the disk.  | 
