From 6cd5b21a263546b8ae3a935ba21efd0991993a4b Mon Sep 17 00:00:00 2001 From: holger krekel Date: Thu, 11 Jun 2026 21:58:59 +0200 Subject: [PATCH] fix: don't send or process webxdc status updates in pre-messages it makes no sense to send or receive status updates in pre-messages for large webxdc attachments because they can't be processed anyway. --- src/mimefactory.rs | 17 +++++++++-------- src/receive_imf.rs | 4 +++- src/tests/pre_messages/receiving.rs | 19 +++++++++++++++++++ 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/mimefactory.rs b/src/mimefactory.rs index 45ea1c6a3..35f952287 100644 --- a/src/mimefactory.rs +++ b/src/mimefactory.rs @@ -1813,14 +1813,15 @@ impl MimeFactory { HeaderDef::IrohGossipTopic.get_headername(), mail_builder::headers::raw::Raw::new(topic).into(), )); - if let (Some(json), _) = context - .render_webxdc_status_update_object( - msg.id, - StatusUpdateSerial::MIN, - StatusUpdateSerial::MAX, - None, - ) - .await? + if !matches!(self.pre_message_mode, PreMessageMode::Pre { .. }) + && let (Some(json), _) = context + .render_webxdc_status_update_object( + msg.id, + StatusUpdateSerial::MIN, + StatusUpdateSerial::MAX, + None, + ) + .await? { parts.push(context.build_status_update_part(&json)); } diff --git a/src/receive_imf.rs b/src/receive_imf.rs index 19d4f9814..c52a3e5dd 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -826,7 +826,9 @@ UPDATE config SET value=? WHERE keyname='configured_addr' AND value!=?1 } } - if let Some(ref status_update) = mime_parser.webxdc_status_update { + if let Some(ref status_update) = mime_parser.webxdc_status_update + && !matches!(mime_parser.pre_message, PreMessageMode::Pre { .. }) + { let can_info_msg; let instance = if mime_parser .parts diff --git a/src/tests/pre_messages/receiving.rs b/src/tests/pre_messages/receiving.rs index 953b07c1e..6bc1601bb 100644 --- a/src/tests/pre_messages/receiving.rs +++ b/src/tests/pre_messages/receiving.rs @@ -534,6 +534,17 @@ async fn test_webxdc_updates_in_post_message_after_pre_message() -> Result<()> { let alice_chat_id = alice.create_chat_id(bob).await; + // regression test where updates get assigned to an unrelated prior webxdc message + let mut unrelated_xdc = Message::new(Viewtype::Webxdc); + unrelated_xdc.set_file_from_bytes( + alice, + "first.xdc", + include_bytes!("../../../test-data/webxdc/minimal.xdc"), + None, + )?; + send_msg(alice, alice_chat_id, &mut unrelated_xdc).await?; + let bob_unrelated_webxdc = bob.recv_msg(&alice.pop_sent_msg().await).await; + let big_webxdc_app = big_webxdc_app().await?; let mut alice_instance = Message::new(Viewtype::Webxdc); @@ -552,6 +563,14 @@ async fn test_webxdc_updates_in_post_message_after_pre_message() -> Result<()> { let bob_instance = bob.recv_msg(&pre_message).await; assert_eq!(bob_instance.download_state, DownloadState::Available); + + // don't accidentally assign updates from a pre-message to parent message + assert_eq!( + bob.get_webxdc_status_updates(bob_unrelated_webxdc.id, StatusUpdateSerial::new(0)) + .await?, + "[]" + ); + bob.recv_msg_trash(&post_message).await; let bob_instance = Message::load_from_db(bob, bob_instance.id).await?; assert_eq!(bob_instance.download_state, DownloadState::Done);