refactor: Remove unused parameter and return value from build_body_file(…) (#6369)

2 simple refactoring commits that remove some unused code.
This commit is contained in:
Hocuri
2024-12-27 17:35:08 +01:00
committed by GitHub
parent 137e32fe49
commit 0cadfe34ae

View File

@@ -1369,7 +1369,7 @@ impl MimeFactory {
// add attachment part // add attachment part
if msg.viewtype.has_file() { 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); parts.push(file_part);
} }
@@ -1509,11 +1509,7 @@ pub(crate) fn wrapped_base64_encode(buf: &[u8]) -> String {
.join("\r\n") .join("\r\n")
} }
async fn build_body_file( async fn build_body_file(context: &Context, msg: &Message) -> Result<PartBuilder> {
context: &Context,
msg: &Message,
base_name: &str,
) -> Result<(PartBuilder, String)> {
let blob = msg let blob = msg
.param .param
.get_blob(Param::File, context) .get_blob(Param::File, context)
@@ -1539,17 +1535,13 @@ async fn build_body_file(
), ),
Viewtype::Image | Viewtype::Gif => format!( Viewtype::Image | Viewtype::Gif => format!(
"image_{}.{}", "image_{}.{}",
if base_name.is_empty() {
chrono::Utc chrono::Utc
.timestamp_opt(msg.timestamp_sort, 0) .timestamp_opt(msg.timestamp_sort, 0)
.single() .single()
.map_or_else( .map_or_else(
|| "YY-mm-dd_hh:mm:ss".to_string(), || "YY-mm-dd_hh:mm:ss".to_string(),
|ts| ts.format("%Y-%m-%d_%H-%M-%S").to_string(), |ts| ts.format("%Y-%m-%d_%H-%M-%S").to_string(),
) ),
} else {
base_name.to_string()
},
&suffix, &suffix,
), ),
Viewtype::Video => format!( Viewtype::Video => format!(
@@ -1601,7 +1593,7 @@ async fn build_body_file(
.header(("Content-Transfer-Encoding", "base64")) .header(("Content-Transfer-Encoding", "base64"))
.body(encoded_body); .body(encoded_body);
Ok((mail, filename_to_send)) Ok(mail)
} }
async fn build_avatar_file(context: &Context, path: &str) -> Result<String> { async fn build_avatar_file(context: &Context, path: &str) -> Result<String> {