From 02bfb07c876d86802a723f67f471a4c5e1359a30 Mon Sep 17 00:00:00 2001 From: Ashelyn Rose Date: Mon, 30 Sep 2024 21:17:16 -0600 Subject: Keep attachment description --- src/system.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/system.rs b/src/system.rs index 98bd026..d1f9dc9 100644 --- a/src/system.rs +++ b/src/system.rs @@ -182,11 +182,15 @@ impl System { let attachments = join_all(message.attachments.iter().map(|attachment| async { let filename = attachment.filename.clone(); - let description = attachment.description.clone(); + let description_opt = attachment.description.clone(); let bytes = reqwest::get(attachment.proxy_url.clone()).await?.bytes().await?; + let mut new_attachment = Attachment::from_bytes(filename, bytes.try_into().unwrap(), attachment.id.into()); - // TODO: keep description - Ok(Attachment::from_bytes(filename, bytes.try_into().unwrap(), attachment.id.into())) + if let Some(description) = description_opt { + new_attachment.description(description); + } + + Ok(new_attachment) })).await.iter().filter_map(|result: &Result| match result { Ok(attachment) => Some(attachment.clone()), Err(_) => None, -- cgit 1.4.1