mirror of
https://github.com/chatmail/core.git
synced 2026-04-25 01:16:29 +03:00
Fix #2078
This commit is contained in:
@@ -394,7 +394,7 @@ impl MimeMessage {
|
||||
|
||||
if !subj.is_empty() {
|
||||
for part in self.parts.iter_mut() {
|
||||
if part.typ == Viewtype::Text {
|
||||
if !part.msg.is_empty() {
|
||||
part.msg = format!("{} – {}", subj, part.msg);
|
||||
break;
|
||||
}
|
||||
@@ -1420,7 +1420,14 @@ mod tests {
|
||||
#![allow(clippy::indexing_slicing)]
|
||||
|
||||
use super::*;
|
||||
use crate::test_utils::*;
|
||||
use crate::{
|
||||
chatlist::Chatlist,
|
||||
config::Config,
|
||||
constants::Blocked,
|
||||
dc_receive_imf::dc_receive_imf,
|
||||
message::{Message, MessageState, MessengerMessage},
|
||||
test_utils::*,
|
||||
};
|
||||
use mailparse::ParsedMail;
|
||||
|
||||
impl AvatarAction {
|
||||
@@ -2520,4 +2527,39 @@ On 2020-10-25, Bob wrote:
|
||||
assert_eq!(mimeparser.parts[0].msg, "YIPPEEEEEE\n\nMulti-line");
|
||||
assert_eq!(mimeparser.parts[0].param.get(Param::Quote).unwrap(), "Now?");
|
||||
}
|
||||
|
||||
#[async_std::test]
|
||||
async fn test_add_subj_to_multimedia_msg() {
|
||||
let t = TestContext::new_alice().await;
|
||||
t.set_config(Config::ShowEmails, Some("2")).await.unwrap();
|
||||
dc_receive_imf(
|
||||
&t.ctx,
|
||||
include_bytes!("../test-data/message/subj_with_multimedia_msg.eml"),
|
||||
"INBOX",
|
||||
1,
|
||||
false,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let chats = Chatlist::try_load(&t.ctx, 0, None, None).await.unwrap();
|
||||
let msg_id = chats.get_msg_id(0).unwrap();
|
||||
let msg = Message::load_from_db(&t.ctx, msg_id).await.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
msg.text.as_ref().unwrap(),
|
||||
"subj with important info – body text"
|
||||
);
|
||||
assert_eq!(msg.viewtype, Viewtype::Image);
|
||||
assert_eq!(msg.error(), None);
|
||||
assert_eq!(msg.is_dc_message, MessengerMessage::No);
|
||||
assert_eq!(msg.chat_blocked, Blocked::Deaddrop);
|
||||
assert_eq!(msg.state, MessageState::InFresh);
|
||||
assert_eq!(msg.get_filebytes(&t).await, 2115);
|
||||
assert!(msg.get_file(&t).is_some());
|
||||
assert_eq!(msg.get_filename().unwrap(), "avatar64x64.png");
|
||||
assert_eq!(msg.get_width(), 64);
|
||||
assert_eq!(msg.get_height(), 64);
|
||||
assert_eq!(msg.get_filemime().unwrap(), "image/png");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user