mirror of
https://github.com/chatmail/core.git
synced 2026-05-03 21:36:29 +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::key::{DcKey, SignedPublicKey};
|
||||||
use crate::location;
|
use crate::location;
|
||||||
use crate::log::{info, warn};
|
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::mimeparser::{SystemMessage, is_hidden};
|
||||||
use crate::param::Param;
|
use crate::param::Param;
|
||||||
use crate::peer_channels::create_iroh_header;
|
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,
|
_ => file_name,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* check mimetype */
|
let mimetype = msg
|
||||||
let mimetype = match msg.param.get(Param::MimeType) {
|
.param
|
||||||
Some(mtype) => mtype.to_string(),
|
.get(Param::MimeType)
|
||||||
None => {
|
.unwrap_or("application/octet-stream")
|
||||||
if let Some((_viewtype, res)) = message::guess_msgtype_from_suffix(msg) {
|
.to_string();
|
||||||
res.to_string()
|
|
||||||
} else {
|
|
||||||
"application/octet-stream".to_string()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let body = fs::read(blob.to_abs_path()).await?;
|
let body = fs::read(blob.to_abs_path()).await?;
|
||||||
|
|
||||||
// create mime part, for Content-Disposition, see RFC 2183.
|
// create mime part, for Content-Disposition, see RFC 2183.
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ use crate::chatlist::Chatlist;
|
|||||||
use crate::constants;
|
use crate::constants;
|
||||||
use crate::contact::Origin;
|
use crate::contact::Origin;
|
||||||
use crate::headerdef::HeaderDef;
|
use crate::headerdef::HeaderDef;
|
||||||
|
use crate::message;
|
||||||
use crate::mimeparser::MimeMessage;
|
use crate::mimeparser::MimeMessage;
|
||||||
use crate::receive_imf::receive_imf;
|
use crate::receive_imf::receive_imf;
|
||||||
use crate::test_utils::{TestContext, TestContextManager, get_chat_msg};
|
use crate::test_utils::{TestContext, TestContextManager, get_chat_msg};
|
||||||
|
|||||||
Reference in New Issue
Block a user