How a message is attributed to a chat

Android 10 + DC 1.14.5 and Windows 10 Home + DC 1.14.1

What is the criterion that indicates DC that a message belongs to some special chat?
Originally I had thought, that email-address and time would define which chat should be attributed and what the order of the message in the sequence is. But I found, that sometimes an answer of someone to one of my messages is not sorted into the chat but opens a new chat, despite the email address of the partner did not change.
So again,

  1. what is the tool that indicates what a message is belonging to?
  2. and is there a way, I can merge an answer being presented in a separate chat into the chat it should have been inserted, after I had received it? May be by an action with the email-tool may be by an action with DC?

As far as seen, good Hans, it’s possible to forward a message, although (sadly) info on origin is missing, as well as info that a particulat message was forwarded (there and there “share info”).

In regard of info where belonging to, it’s to assume being part of the messages header.

As messages/emails can not be changed later (unless direct on emailserver’s database, my person is guessing) it’s understandable that re-attributing might be difficult. But something like delete and replace might be maybe technical possible, yet a timeline issue, surely, requiring a seperate list for sorting.

Its in the email headers, I believe the important header for this are Message-ID, References and in reply to.
But better ask @Hocuri or @link2xt as they are more involved with that area of the project.

I have some friends who still use SMS/MMS, so I communicate with them using SMS Email gateways, and if they’re in a “Group”, every message they send arrives as a new chat request. It’s a total mess for the threading. A one-to-one conversation with the same type of account seems to work fine as a single chat though.
Are group chat attributes different from 1-to-1 chat attributes?

This logic is in the most complicated part of the Delta Chat core, namely dc_ prefix is reserved for parts of the core that were ported from C to Rust but never refactored into proper Rust code.

Currently (this applies only to nightly versions and upcoming 1.15 Android releases, Desktop 1.15 still uses stable core) the logic is as follows:

  1. If there is a Chat-Group-Id header pointing to known group chat, we extract Group ID from there.
  2. If there is no Chat-Group-Id, we try to extract Group ID from the Message-ID. This helps if we can’t decrypt the message and Chat-Group-Id header is in the encrypted part.
  3. If the message does not have a Chat-Version header, which means it is a message sent by the client other than Delta Chat, we try to extract Group ID first from the In-Reply-To header, then from the References header. The trick is that Group ID is encoded in Message-IDs, so non-DC clients will put the Message-ID they are replying to in these headers.
  4. If we found the Group ID, we associate message to it’s chat. If we have no such chat, we create it. The only exception is that if the message cannot be decrypted, we do not create a chat because we don’t know the subject/group name. In this case message goes into 1:1 chat with the sender.
  5. If the message does not have a Chat-Version header and we have not found the Group ID so far, we try to find the parent message referenced by In-Reply-To or References in our message database. If we found the message and it belongs to Group chat, we associate the message to the same chat.
  6. If the message is not yet associated to any chat, we try to create so-called Ad-Hoc Group. First, we check that there are at least two members, otherwise it does not make sense to create a group and message goes into 1:1 chat with the sender. Email addresses of all the members are sorted, lowercased, joined with a comma separator and hashed. The result is used as a Group ID. The idea is to ensure that all Delta Chats generate the same Group ID for this group, so it is not split later when they start replying to it. This part is not properly tested and may be the source of your problems, especially if SMS gateway uses different/random From address for each incoming message.
  7. If the message is not yet assigned to any Group, we try to assign it to mailing list. This only happens if the message has List-Id header, it’s a new feature for the upcoming release, so I will skip the details.
  8. Finally, the message is assigned to 1:1 chat as a last resort.

There are some exceptions like location streaming messages, various “secure join” messages that are either hidden but still assigned to normal chats or assigned to hidden chats like the trash chat, but if you see the message then it’s not the case.


Thank You for the comprehensive explanation of the attribution criterion hierarchy.
It sounds quite reasonable from my very limited understanding of this.

What I observe is, that getting multiple messages from the same person, sent with delta chat, but probably written from the scratch to my contact, not written as a direct answer from within an existing chat with me, it is displayed in a new chat on my side.
I got an accompanying message written at a grey background with white letters within the new chat: ‘changed setup for <sender’s email adress>

  • What causes a change of setup on the sender’s side?

I looked into the header and found not many of the Id’s, mentioned in Your list of criterions:

Message-ID: <… some cryptic unknown email address>
To: < my email-address>
From: < senders email adress>
X-Provags-ID: … a very long cryptic sequence of signs …

  • Which of them is relevant for the attribtution to a chat?

Thank You for commenting on it

Thank You for redirecting my request to right people

Are these messages sent to a group? If they are assigned to a new group each time, then one of the email providers (either yours or the other side) strips the Chat-Group-ID from emails and Message-ID. This is a typical behavior of outlook/hotmail: Problem in using

What causes a change of setup on the sender’s side?

This means that Autocrypt header has changed. Probably you have received a message with Autocrypt header, and then without Autocrypt header (because it was removed by the email provider).

I looked into the header and found not many of the Id’s, mentioned in Your list of criterions:

If Message-Id is not of the form or same but with Mr. prefix, then some provider is rewriting Message-IDs. If there is no Chat-Group-ID in the message sent to the group, then provider also removes this header. Also there must always be an Autocrypt header in messages sent by Delta Chat.

Reasonably one should mean, this message is sent to me, not to a group, as no one else than me receives it.
BUT: All my chats tell there are 3members in my chat. I’m occuring twice in this group plus my chat partner as the third person. Once my person is called “I” and once it is called by “my name”. Maybe, this confusing situation might be explained by my advanced settings entry to send a copy to myself?

The mail does contain an autocrypt header.

The Message Id starts with Mr.

Could you check From, To and Cc headers? As you said above, there are only To and From addresses.

Maybe the To address is not same as the email address in the settings? Then it is treated as a separate (third) member and displayed as “your name”. What address does it have?