diff --git a/deltachat-rpc-client/tests/test_something.py b/deltachat-rpc-client/tests/test_something.py index fe329b4bf..8e5fa3085 100644 --- a/deltachat-rpc-client/tests/test_something.py +++ b/deltachat-rpc-client/tests/test_something.py @@ -11,7 +11,7 @@ from unittest.mock import MagicMock import pytest from deltachat_rpc_client import EventType, events -from deltachat_rpc_client.const import DownloadState, MessageState +from deltachat_rpc_client.const import DownloadState, MessageState, ViewType from deltachat_rpc_client.pytestplugin import E2EE_INFO_MSGS from deltachat_rpc_client.rpc import JsonRpcError, Rpc @@ -550,7 +550,7 @@ def test_import_export_online_all(acfactory, tmp_path, data, log) -> None: assert len(ac1.get_contacts()) == 1 original_image_path = data.get_path("image/avatar64x64.png") - chat1.send_file(str(original_image_path)) + chat1.send_message(file=str(original_image_path), viewtype=ViewType.IMAGE) # Add another 100KB file that ensures that the progress is smooth enough path = tmp_path / "attachment.txt" diff --git a/src/blob/blob_tests.rs b/src/blob/blob_tests.rs index 014a2cce4..bbc4bd6f3 100644 --- a/src/blob/blob_tests.rs +++ b/src/blob/blob_tests.rs @@ -421,6 +421,7 @@ async fn test_recode_image_balanced_png() { extension: "png", original_width: 1920, original_height: 1080, + res_viewtype: Some(Viewtype::File), compressed_width: 1920, compressed_height: 1080, ..Default::default() @@ -436,6 +437,7 @@ async fn test_recode_image_balanced_png() { extension: "png", original_width: 1920, original_height: 1080, + res_viewtype: Some(Viewtype::File), compressed_width: 1920, compressed_height: 1080, set_draft: true, @@ -605,8 +607,10 @@ impl SendImageCheckMediaquality<'_> { } let sent = alice.send_msg(chat.id, &mut msg).await; let alice_msg = alice.get_last_msg().await; - assert_eq!(alice_msg.get_width() as u32, compressed_width); - assert_eq!(alice_msg.get_height() as u32, compressed_height); + if viewtype != Viewtype::File { + assert_eq!(alice_msg.get_width() as u32, compressed_width); + assert_eq!(alice_msg.get_height() as u32, compressed_height); + } let file_saved = alice .get_blobdir() .join("saved-".to_string() + &alice_msg.get_filename().unwrap()); @@ -621,8 +625,10 @@ impl SendImageCheckMediaquality<'_> { let bob_msg = bob.recv_msg(&sent).await; assert_eq!(bob_msg.get_viewtype(), res_viewtype); - assert_eq!(bob_msg.get_width() as u32, compressed_width); - assert_eq!(bob_msg.get_height() as u32, compressed_height); + if viewtype != Viewtype::File { + assert_eq!(bob_msg.get_width() as u32, compressed_width); + assert_eq!(bob_msg.get_height() as u32, compressed_height); + } let file_saved = bob .get_blobdir() .join("saved-".to_string() + &bob_msg.get_filename().unwrap()); diff --git a/src/chat.rs b/src/chat.rs index 2fd8b000a..7ece2231f 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -2464,18 +2464,10 @@ async fn prepare_msg_blob(context: &Context, msg: &mut Message) -> Result<()> { .param .get_file_blob(context)? .with_context(|| format!("attachment missing for message of type #{}", msg.viewtype))?; - let mut maybe_image = false; if msg.viewtype == Viewtype::File || msg.viewtype == Viewtype::Image { - // Correct the type, take care not to correct already very special - // formats as GIF or VOICE. - // - // Typical conversions: - // - from FILE to AUDIO/VIDEO/IMAGE - // - from FILE/IMAGE to GIF */ if let Some((better_type, _)) = message::guess_msgtype_from_suffix(msg) { if better_type == Viewtype::Image { - maybe_image = true; } else if better_type != Viewtype::Webxdc || context .ensure_sendable_webxdc_file(&blob.to_abs_path()) @@ -2494,7 +2486,7 @@ async fn prepare_msg_blob(context: &Context, msg: &mut Message) -> Result<()> { if msg.viewtype == Viewtype::Vcard { msg.try_set_vcard(context, &blob.to_abs_path()).await?; } - if msg.viewtype == Viewtype::File && maybe_image || msg.viewtype == Viewtype::Image { + if msg.viewtype == Viewtype::Image { let new_name = blob .check_or_recode_image(context, msg.get_filename(), &mut msg.viewtype) .await?;