-
-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add device message about outgoing undecryptable messages (#5164)
Currently when a user sets up another device by logging in, a new key is created. If a message is sent from either device outside, it cannot be decrypted by the other device. The message is replaced with square bracket error like this: ``` <string name="systemmsg_cannot_decrypt">This message cannot be decrypted.\n\n• It might already help to simply reply to this message and ask the sender to send the message again.\n\n• If you just re-installed Delta Chat then it is best if you re-setup Delta Chat now and choose "Add as second device" or import a backup.</string> ``` (taken from Android repo `res/values/strings.xml`) If the message is outgoing, it does not help to "simply reply to this message". Instead, we should add a translatable device message of a special type so UI can link to the FAQ entry about second device. But let's limit such notifications to 1 per day. And as for the undecryptable message itself, let it go to Trash, it's unlikely that this will break subsequent messages chat assignment, anyway this undecryptable message wouldn't be assigned to the correct chat as well.
- Loading branch information
Showing
8 changed files
with
107 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,11 +28,24 @@ async fn test_grpid_simple() { | |
let mimeparser = MimeMessage::from_bytes(&context.ctx, &raw[..], None) | ||
.await | ||
.unwrap(); | ||
assert_eq!(mimeparser.incoming, true); | ||
assert_eq!(extract_grpid(&mimeparser, HeaderDef::InReplyTo), None); | ||
let grpid = Some("HcxyMARjyJy"); | ||
assert_eq!(extract_grpid(&mimeparser, HeaderDef::References), grpid); | ||
} | ||
|
||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] | ||
async fn test_outgoing() -> Result<()> { | ||
let context = TestContext::new_alice().await; | ||
let raw = b"Received: (Postfix, from userid 1000); Mon, 4 Dec 2006 14:51:39 +0100 (CET)\n\ | ||
From: [email protected]\n\ | ||
\n\ | ||
hello"; | ||
let mimeparser = MimeMessage::from_bytes(&context.ctx, &raw[..], None).await?; | ||
assert_eq!(mimeparser.incoming, false); | ||
Ok(()) | ||
} | ||
|
||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] | ||
async fn test_bad_from() { | ||
let context = TestContext::new_alice().await; | ||
|
@@ -3139,6 +3152,42 @@ async fn test_blocked_contact_creates_group() -> Result<()> { | |
Ok(()) | ||
} | ||
|
||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] | ||
async fn test_outgoing_undecryptable() -> Result<()> { | ||
let alice = &TestContext::new().await; | ||
alice.configure_addr("[email protected]").await; | ||
|
||
let raw = include_bytes!("../../test-data/message/thunderbird_with_autocrypt.eml"); | ||
receive_imf(alice, raw, false).await?; | ||
|
||
let bob_contact_id = Contact::lookup_id_by_addr(alice, "[email protected]", Origin::OutgoingTo) | ||
.await? | ||
.unwrap(); | ||
assert!(ChatId::lookup_by_contact(alice, bob_contact_id) | ||
.await? | ||
.is_none()); | ||
|
||
let dev_chat_id = ChatId::lookup_by_contact(alice, ContactId::DEVICE) | ||
.await? | ||
.unwrap(); | ||
let dev_msg = alice.get_last_msg_in(dev_chat_id).await; | ||
assert!(dev_msg.error().is_none()); | ||
assert!(dev_msg | ||
.text | ||
.contains(&stock_str::cant_decrypt_outgoing_msgs(alice).await)); | ||
|
||
let raw = include_bytes!("../../test-data/message/thunderbird_encrypted_signed.eml"); | ||
receive_imf(alice, raw, false).await?; | ||
|
||
assert!(ChatId::lookup_by_contact(alice, bob_contact_id) | ||
.await? | ||
.is_none()); | ||
// The device message mustn't be added too frequently. | ||
assert_eq!(alice.get_last_msg_in(dev_chat_id).await.id, dev_msg.id); | ||
|
||
Ok(()) | ||
} | ||
|
||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] | ||
async fn test_thunderbird_autocrypt() -> Result<()> { | ||
let t = TestContext::new_bob().await; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,6 @@ User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 | |
Content-Language: en-US | ||
To: [email protected] | ||
From: Alice <[email protected]> | ||
X-Mozilla-Draft-Info: internal/draft; vcard=0; receipt=0; DSN=0; uuencode=0; | ||
attachmentreminder=0; deliveryformat=0 | ||
X-Identity-Key: id3 | ||
Fcc: imap://alice%[email protected]/Sent | ||
Subject: ... | ||
|