deltachat / deltachat-core-rust

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

Two groups accidentally created while fetching pending messages after backup restore #5385

Open gerryfrancis opened 5 months ago

gerryfrancis commented 5 months ago
gerryfrancis commented 3 months ago

FYI, it happens with version 1.45.0 (beta), too.

iequidoo commented 3 months ago

A fix i can imagine here is to sort by INTERNALDATE not only messages from a particular folder, but from all folders, before passing them to receive_imf_inner(). The problem is that folders are processed by different threads, so it will be actually not sorting, but some kind of synchronisation using e.g. tokio::sync::Notify + Mutex. Not too difficult to implement, but still quite a big change so it's a question whether fixing this is worth it. Maybe also a topo-sorting using the References header is a way.

iequidoo commented 3 months ago

Another possible fix is to leave this unordered processing of folders as is, but search Message-ID in the already known references, this way we can insert an unordered ("missed previously") message to the already existing chat.

EDIT: the problem is that several messages may be unordered, in this case we know the proper chat for them only when processing the last unordered message. Merging chats looks too complicated to fix this, some INTERNALDATE sorting-based solution could be better.

EDIT: A better possible fix: even if a message doesn't reference any known message, but has the same subject (without prefix) and "group members" as an already existing ad-hoc group, use that group for the new message.