From 21d13e8a9c0fda73be70a242128998a0d1c0d42d Mon Sep 17 00:00:00 2001 From: Hocuri Date: Wed, 14 May 2025 16:14:35 +0200 Subject: [PATCH] fix: Don't change webxdc self-addr when saving and loading draft (#6854) Fix https://github.com/chatmail/core/issues/6621; I also tested on Android that the webxdc self-addr actually stays the same when staging a draft and then sending. Follow-up to https://github.com/chatmail/core/pull/6704; #6704 made sure that the webxdc self-addr doesn't change when creating a message and then sending it. This PR here makes sure that the rfc724_mid (which is needed to compute the self-addr) is saved when setting a draft, so that it's loaded properly after a call to get_draft(). cc @adbenitez @r10s @Septias --- src/chat.rs | 4 +++- src/webxdc/webxdc_tests.rs | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/chat.rs b/src/chat.rs index 2e68bc4cd..e23e1607f 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -995,6 +995,7 @@ impl ChatId { transaction.execute( "INSERT INTO msgs ( chat_id, + rfc724_mid, from_id, timestamp, type, @@ -1004,9 +1005,10 @@ impl ChatId { param, hidden, mime_in_reply_to) - VALUES (?,?,?,?,?,?,?,?,?,?);", + VALUES (?,?,?,?,?,?,?,?,?,?,?);", ( self, + &msg.rfc724_mid, ContactId::SELF, time(), msg.viewtype, diff --git a/src/webxdc/webxdc_tests.rs b/src/webxdc/webxdc_tests.rs index c0a9d347c..5b7b6309d 100644 --- a/src/webxdc/webxdc_tests.rs +++ b/src/webxdc/webxdc_tests.rs @@ -2210,6 +2210,7 @@ async fn test_self_addr_consistency() -> Result<()> { include_bytes!("../../test-data/webxdc/minimal.xdc"), )?; alice_chat.set_draft(alice, Some(&mut instance)).await?; + let mut instance = alice_chat.get_draft(alice).await?.unwrap(); let self_addr = instance.get_webxdc_self_addr(alice).await?; let sent = alice.send_msg(alice_chat, &mut instance).await; let db_msg = Message::load_from_db(alice, sent.sender_msg_id).await?;