mirror of
https://github.com/chatmail/core.git
synced 2026-04-02 05:22:14 +03:00
refactor: build_body_file(): Remove guessing mimetype by file extension
Guessing mimetype is already done in `chat::prepare_msg_blob()`.
This commit is contained in:
@@ -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<MimePart<'s
|
||||
_ => 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.
|
||||
|
||||
@@ -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};
|
||||
|
||||
Reference in New Issue
Block a user