Generate rfc724_mid when creating Message (#6704)

Set `rfc724_mid` in `Message::new()`, `Message::new_text()`, and
`Message::default()` instead of when sending the message. This way the
rfc724 mid can be read in the draft stage which makes it more consistent
for bots. Tests had to be adjusted to create multiple messages to get
unique mid, otherwise core would not send the messages out.
This commit is contained in:
Sebastian Klähn
2025-05-05 17:06:05 +02:00
committed by GitHub
parent 98a1b9e373
commit 846c8e7f1b
9 changed files with 57 additions and 22 deletions

View File

@@ -2195,3 +2195,25 @@ async fn test_webxdc_href() -> Result<()> {
Ok(())
}
/// Test that the draft `selfAddr` is equal to the `selfAddr` of the sent message.
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_self_addr_consistency() -> Result<()> {
let mut tcm = TestContextManager::new();
let alice = &tcm.alice().await;
let alice_chat = alice
.create_group_with_members(ProtectionStatus::Unprotected, "No friends :(", &[])
.await;
let mut instance = create_webxdc_instance(
alice,
"minimal.xdc",
include_bytes!("../../test-data/webxdc/minimal.xdc"),
)?;
alice_chat.set_draft(alice, Some(&mut instance)).await?;
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?;
assert_eq!(db_msg.get_webxdc_self_addr(alice).await?, self_addr);
assert_eq!(alice_chat.get_msg_cnt(alice).await?, 1);
Ok(())
}