diff --git a/src/mimefactory.rs b/src/mimefactory.rs index cb0d625c4..bdc5f49ab 100644 --- a/src/mimefactory.rs +++ b/src/mimefactory.rs @@ -27,7 +27,7 @@ use crate::key::self_fingerprint; use crate::key::{DcKey, SignedPublicKey}; use crate::location; use crate::log::{info, warn}; -use crate::message::{self, Message, MsgId, Viewtype}; +use crate::message::{Message, MsgId, Viewtype}; use crate::mimeparser::{SystemMessage, is_hidden}; use crate::param::Param; use crate::peer_channels::create_iroh_header; @@ -1821,18 +1821,11 @@ async fn build_body_file(context: &Context, msg: &Message) -> Result file_name, }; - /* check mimetype */ - let mimetype = match msg.param.get(Param::MimeType) { - Some(mtype) => mtype.to_string(), - None => { - if let Some((_viewtype, res)) = message::guess_msgtype_from_suffix(msg) { - res.to_string() - } else { - "application/octet-stream".to_string() - } - } - }; - + let mimetype = msg + .param + .get(Param::MimeType) + .unwrap_or("application/octet-stream") + .to_string(); let body = fs::read(blob.to_abs_path()).await?; // create mime part, for Content-Disposition, see RFC 2183. diff --git a/src/mimefactory/mimefactory_tests.rs b/src/mimefactory/mimefactory_tests.rs index c34b9be66..95a1e41a5 100644 --- a/src/mimefactory/mimefactory_tests.rs +++ b/src/mimefactory/mimefactory_tests.rs @@ -12,6 +12,7 @@ use crate::chatlist::Chatlist; use crate::constants; use crate::contact::Origin; use crate::headerdef::HeaderDef; +use crate::message; use crate::mimeparser::MimeMessage; use crate::receive_imf::receive_imf; use crate::test_utils::{TestContext, TestContextManager, get_chat_msg};