From c68cfa37c9f7f888910d51a3c4a61b8dc94028bd Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Fri, 24 Apr 2026 22:23:52 +0200 Subject: [PATCH] feat: only convert Viewtype::Image to Audio/Video/Gif, Viewtype::File to Webxdc --- src/chat.rs | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/chat.rs b/src/chat.rs index 7ece2231f..5c466a462 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -2465,17 +2465,24 @@ async fn prepare_msg_blob(context: &Context, msg: &mut Message) -> Result<()> { .get_file_blob(context)? .with_context(|| format!("attachment missing for message of type #{}", msg.viewtype))?; - if msg.viewtype == Viewtype::File || msg.viewtype == Viewtype::Image { - if let Some((better_type, _)) = message::guess_msgtype_from_suffix(msg) { - if better_type == Viewtype::Image { - } else if better_type != Viewtype::Webxdc - || context - .ensure_sendable_webxdc_file(&blob.to_abs_path()) - .await - .is_ok() - { - msg.viewtype = better_type; - } + if msg.viewtype == Viewtype::Image { + if let Some((better_type, _)) = message::guess_msgtype_from_suffix(msg) + && (better_type == Viewtype::Video + || better_type == Viewtype::Audio + || better_type == Viewtype::Gif) + { + msg.viewtype = better_type; + } + } else if msg.viewtype == Viewtype::File { + if let Some((better_type, _)) = message::guess_msgtype_from_suffix(msg) + && (better_type == Viewtype::Vcard + || better_type == Viewtype::Webxdc + && context + .ensure_sendable_webxdc_file(&blob.to_abs_path()) + .await + .is_ok()) + { + msg.viewtype = better_type; } } else if msg.viewtype == Viewtype::Webxdc { context