This commit is contained in:
Hocuri
2020-12-17 19:05:08 +01:00
parent 2b207e1375
commit 9edc6702f1
2 changed files with 111 additions and 2 deletions

View File

@@ -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");
}
}