deltachat / deltachat-core-rust

Delta Chat Rust Core library, used by Android/iOS/desktop apps, bindings and bots 📧
https://delta.chat/en/contribute
Other
679 stars 86 forks source link

Download limit prevents group creation #4757

Closed webratte closed 1 year ago

webratte commented 1 year ago
gerryfrancis commented 1 year ago

Probably related: https://github.com/deltachat/deltachat-core-rust/issues/4543

adbenitez commented 1 year ago

following the steps, indeed it is as you described, thanks a lot for reporting, but this is not an android issue but delta chat core issue (ex. it also happens in Desktop) so I am moving to core

iequidoo commented 1 year ago

I think a possible solution is if there are attachments or an initial message is quite big, they should be sent in a separate message after the group creation. CC @link2xt

link2xt commented 1 year ago

Is it possible to make a receiver-side solution? What happens currently, message lands into 1:1 chat, adhoc group or goes to trash? Is it possible to click "download" on it? Ideally I would expect the message to go to 1:1 chat with the sender and when you download it result in a new group being created.

Avoiding attachments in unpromoted group may help a bit, but for large enough groups the message may get large because of too many autocrypt gossip keys, e.g. if you want to make a group with 30 members or when you add a new member to such group.

iequidoo commented 1 year ago

Ideally I would expect the message to go to 1:1 chat with the sender and when you download it result in a new group being created.

It's how it works currently. The only thing is that the message isn't removed from the 1:1 chat after downloading. As a result it is in the both chats.

UPD: It works so even if the message is received from a new contact (i.e. there was no 1:1 chat with it before)

link2xt commented 1 year ago

The only thing is that the message isn't removed from the 1:1 chat after downloading.

Then this is actual bug, once fixed I think we can close the issue.

iequidoo commented 1 year ago

No, i was wrong. I tested it in the CLI client and wasn't attentive enough :) So, for messages with big attachments it works as expected, creating a new group even before the message is downloaded. But if the attachment is a webxdc app, it doesn't work:

 INFO  deltachat_repl > src/imap/idle.rs:74: INBOX: Idle has NewData ResponseData { raw: 4096, response: MailboxData(Recent(1)) }
 INFO  deltachat_repl > src/job.rs:264: Loading job.
 INFO  deltachat_repl > src/imap.rs:886: 1 mails read from "INBOX".
 INFO  deltachat_repl > src/imap/idle.rs:74: DeltaChat: Idle has NewData ResponseData { raw: 4096, response: MailboxData(Recent(5)) }
 INFO  deltachat_repl > Received ImapMessageMoved("IMAP messages 88 moved to DeltaChat")
 INFO  deltachat_repl > src/imap/scan_folders.rs:27: Starting full folder scan
 INFO  deltachat_repl > src/imap.rs:1792: Need to fetch again, got unsolicited EXISTS Exists(6)
 INFO  deltachat_repl > src/imap.rs:1813: got unsolicited response Other(ResponseData { raw: 4096, response: Data { status: Ok, code: Some(CopyUid(171, [Uid(88)], [Uid(18)])), information: None } })
 INFO  deltachat_repl > src/imap.rs:1792: Need to fetch again, got unsolicited EXISTS Exists(5)
 INFO  deltachat_repl > src/imap.rs:718: No new emails in folder "Archive".
 INFO  deltachat_repl > Received ConnectivityChanged
 INFO  deltachat_repl > src/imap.rs:1408: Starting a partial FETCH of message set "18".
 INFO  deltachat_repl > src/imap.rs:718: No new emails in folder "Junk".
 INFO  deltachat_repl > src/imap.rs:1526: Passing message UID 18 to receive_imf().
 INFO  deltachat_repl > src/receive_imf.rs:103: Receiving message, seen=false...
 INFO  deltachat_repl > src/download.rs:248: Partial download: [480.93 KiB message]
 INFO  deltachat_repl > src/receive_imf.rs:142: Received message has Message-Id: Gr.Q92H-PiQf44.aEZZIlZ2Wpx@gmail.com
 INFO  deltachat_repl > src/receive_imf.rs:1644: Message belongs to unwanted group (TRASH).
 INFO  deltachat_repl > src/receive_imf.rs:1278: Message has 1 parts and is assigned to chat #Chat#Trash.
iequidoo commented 1 year ago

I'm wrong again :) It depends not on whether it's a webxdc app or smth else, but on whether it's encrypted or not. Because Chat-Group-Id is a protected header and we need to download the message to see it.

UPD: So, it works as expected only for unencrypted messages.

link2xt commented 1 year ago

Because Chat-Group-Id is a protected header and we need to download the message to see it.

We do not prefetch Chat-Group-Id in any case, so I don't understand why message being unencrypted helps.

iequidoo commented 1 year ago

We do not prefetch Chat-Group-Id in any case, so I don't understand why message being unencrypted helps.

But it works, i rechecked it:

 INFO  deltachat_repl > src/imap.rs:1408: Starting a partial FETCH of message set "23".
 INFO  deltachat_repl > src/imap/idle.rs:59: INBOX: Idle entering wait-on-remote state
 INFO  deltachat_repl > src/imap.rs:1526: Passing message UID 23 to receive_imf().
 INFO  deltachat_repl > src/receive_imf.rs:103: Receiving message, seen=false...
 INFO  deltachat_repl > src/download.rs:248: Partial download: [90.28 KiB message]
 INFO  deltachat_repl > src/receive_imf.rs:142: Received message has Message-Id: Gr.qEbuLCxzTlG.ija_18Xtu5V@gmail.com
 INFO  deltachat_repl > src/chat.rs:290: Created group/mailinglist '#4757-6' grpid=qEbuLCxzTlG as Chat#22, blocked=Not.
 INFO  deltachat_repl > Received CHAT_MODIFIED(Chat#22)
 INFO  deltachat_repl > src/receive_imf.rs:1278: Message has 1 parts and is assigned to chat #Chat#22.
 INFO  deltachat_repl > Received IncomingMsg { chat_id: ChatId(22), msg_id: MsgId(36) }
 INFO  deltachat_repl > src/contact.rs:1659: Recently seen loop waiting for 0h 5m 59s or interrupt
 INFO  deltachat_repl > src/imap.rs:1565: Successfully received 1 UIDs.
 INFO  deltachat_repl > src/imap.rs:886: 1 mails read from "DeltaChat".
 INFO  deltachat_repl > Received IncomingMsgBunch { msg_ids: [MsgId(36)] }
iequidoo commented 1 year ago

It works because Chat-Group-Id is duplicated in the Message-Id header and we have unencrypted Subject

iequidoo commented 1 year ago

With this simple fix it started working for encrypted messages also (after downloading a message moves from 1:1 chat to a new group):

@@ -1630,7 +1633,7 @@ async fn self_explicitly_added(                                                                                                                                                                

     if let Some(chat_id) = chat_id {                                                                                                                                                                                
         Ok(Some((chat_id, chat_id_blocked)))                                                                                                                                                                        
-    } else if mime_parser.decrypting_failed {                                                                                                                                                                       
+    } else if is_partial_download || mime_parser.decrypting_failed {                                                                                                                                                
         // It is possible that the message was sent to a valid,                                                                                                                                                     
         // yet unknown group, which was rejected because                                                                                                                                                            
         // Chat-Group-Name, which is in the encrypted part, was

But this needs a new test of course

iequidoo commented 1 year ago

Fixed in #4801