Match delivered-to as last

This commit is contained in:
M66B 2020-12-13 15:57:12 +01:00
parent 47c070d543
commit 4c20128715
2 changed files with 14 additions and 6 deletions

1
FAQ.md
View File

@ -1318,6 +1318,7 @@ Note that this is independent of receiving messages.
Identities are as expected matched by account.
For incoming messages the *to*, *cc*, *bcc*, *from* and *(X-)delivered/envelope/original-to* addresses will be checked (in this order)
and for outgoing messages (drafts, outbox and sent) only the *from* addresses will be checked.
Equal addresses have precedence over partially matching addresses, except for *delivered-to* addresses.
The matched address will be shown as *via* in the addresses section of received messages (between the message header and message text).

View File

@ -3113,14 +3113,16 @@ class Core {
addresses.addAll(Arrays.asList(message.bcc));
if (message.from != null)
addresses.addAll(Arrays.asList(message.from));
if (message.deliveredto != null)
try {
addresses.add(new InternetAddress(message.deliveredto));
} catch (AddressException ex) {
Log.w(ex);
}
}
InternetAddress deliveredto = null;
if (message.deliveredto != null)
try {
deliveredto = new InternetAddress(message.deliveredto);
} catch (AddressException ex) {
Log.w(ex);
}
// Search for matching identity
List<EntityIdentity> identities = db.identity().getSynchronizingIdentities(folder.account);
if (identities != null) {
@ -3133,6 +3135,11 @@ class Core {
for (EntityIdentity identity : identities)
if (identity.similarAddress(address))
return identity;
if (deliveredto != null)
for (EntityIdentity identity : identities)
if (identity.sameAddress(deliveredto) || identity.similarAddress(deliveredto))
return identity;
}
return null;