mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
fix: Allow to save a draft if the verification is broken (#4542)
If the verification is broken, `can_send()` is false. But if the user was typing a message right when a verification-breaking message came in, the UI still needs to be able to save it as a draft. Steps to reproduce the bug: - Set a draft - Your chat partner breaks verification - Go back to the chats list - Go to the chat again - Accept the breakage - Expected: The draft is still there - Bug behavior: The draft is gone
This commit is contained in:
@@ -761,14 +761,6 @@ impl ChatId {
|
||||
}
|
||||
}
|
||||
|
||||
let chat = Chat::load_from_db(context, self).await?;
|
||||
if let Some(cant_send_reason) = chat.why_cant_send(context).await? {
|
||||
bail!(
|
||||
"Can't set a draft because chat is not writeable: {}",
|
||||
cant_send_reason
|
||||
);
|
||||
}
|
||||
|
||||
// set back draft information to allow identifying the draft later on -
|
||||
// no matter if message object is reused or reloaded from db
|
||||
msg.state = MessageState::OutDraft;
|
||||
|
||||
@@ -5,7 +5,7 @@ use crate::chat::{Chat, ProtectionStatus};
|
||||
use crate::config::Config;
|
||||
use crate::contact::VerifiedStatus;
|
||||
use crate::contact::{Contact, Origin};
|
||||
use crate::message::Message;
|
||||
use crate::message::{Message, Viewtype};
|
||||
use crate::mimefactory::MimeFactory;
|
||||
use crate::mimeparser::SystemMessage;
|
||||
use crate::receive_imf::receive_imf;
|
||||
@@ -461,14 +461,21 @@ async fn test_break_protection_then_verify_again() -> Result<()> {
|
||||
|
||||
tcm.send_recv(&bob_new, &alice, "I have a new device").await;
|
||||
assert_verified(&alice, &bob_new, ProtectionStatus::ProtectionBroken).await;
|
||||
assert!(
|
||||
!alice
|
||||
.get_chat(&bob_new)
|
||||
.await
|
||||
.unwrap()
|
||||
.can_send(&alice)
|
||||
.await?
|
||||
);
|
||||
|
||||
{
|
||||
let alice_bob_chat = alice.get_chat(&bob_new).await.unwrap();
|
||||
assert!(!alice_bob_chat.can_send(&alice).await?);
|
||||
|
||||
// Alice's UI should still be able to save a draft, which Alice started to type right when she got Bob's message:
|
||||
let mut msg = Message::new(Viewtype::Text);
|
||||
msg.set_text("Draftttt".to_string());
|
||||
alice_bob_chat.id.set_draft(&alice, Some(&mut msg)).await?;
|
||||
assert_eq!(
|
||||
alice_bob_chat.id.get_draft(&alice).await?.unwrap().text,
|
||||
"Draftttt"
|
||||
);
|
||||
}
|
||||
|
||||
tcm.execute_securejoin(&alice, &bob_new).await;
|
||||
assert_verified(&alice, &bob_new, ProtectionStatus::Protected).await;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user