From 0cadfe34ae6b16d41388f0f12160f675f1c1f0e3 Mon Sep 17 00:00:00 2001 From: Hocuri Date: Fri, 27 Dec 2024 17:35:08 +0100 Subject: [PATCH] =?UTF-8?q?refactor:=20Remove=20unused=20parameter=20and?= =?UTF-8?q?=20return=20value=20from=20`build=5Fbody=5Ffile(=E2=80=A6)`=20(?= =?UTF-8?q?#6369)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2 simple refactoring commits that remove some unused code. --- src/mimefactory.rs | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/src/mimefactory.rs b/src/mimefactory.rs index 8f5f66f01..8af37c938 100644 --- a/src/mimefactory.rs +++ b/src/mimefactory.rs @@ -1369,7 +1369,7 @@ impl MimeFactory { // add attachment part if msg.viewtype.has_file() { - let (file_part, _) = build_body_file(context, &msg, "").await?; + let file_part = build_body_file(context, &msg).await?; parts.push(file_part); } @@ -1509,11 +1509,7 @@ pub(crate) fn wrapped_base64_encode(buf: &[u8]) -> String { .join("\r\n") } -async fn build_body_file( - context: &Context, - msg: &Message, - base_name: &str, -) -> Result<(PartBuilder, String)> { +async fn build_body_file(context: &Context, msg: &Message) -> Result { let blob = msg .param .get_blob(Param::File, context) @@ -1539,17 +1535,13 @@ async fn build_body_file( ), Viewtype::Image | Viewtype::Gif => format!( "image_{}.{}", - if base_name.is_empty() { - chrono::Utc - .timestamp_opt(msg.timestamp_sort, 0) - .single() - .map_or_else( - || "YY-mm-dd_hh:mm:ss".to_string(), - |ts| ts.format("%Y-%m-%d_%H-%M-%S").to_string(), - ) - } else { - base_name.to_string() - }, + chrono::Utc + .timestamp_opt(msg.timestamp_sort, 0) + .single() + .map_or_else( + || "YY-mm-dd_hh:mm:ss".to_string(), + |ts| ts.format("%Y-%m-%d_%H-%M-%S").to_string(), + ), &suffix, ), Viewtype::Video => format!( @@ -1601,7 +1593,7 @@ async fn build_body_file( .header(("Content-Transfer-Encoding", "base64")) .body(encoded_body); - Ok((mail, filename_to_send)) + Ok(mail) } async fn build_avatar_file(context: &Context, path: &str) -> Result {