1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-03-19 10:25:29 +00:00

Prefer same/similar address from extra

This commit is contained in:
M66B 2019-12-24 09:53:02 +01:00
parent d26ba9dd92
commit 7bc405537d

View file

@ -2768,7 +2768,24 @@ public class FragmentCompose extends FragmentBase {
}
if (data.draft.from != null && data.draft.from.length > 0) {
String from = ((InternetAddress) data.draft.from[0]).getAddress();
Address preferred = null;
if (ref.identity != null) {
EntityIdentity recognized = db.identity().getIdentity(ref.identity);
if (recognized != null) {
Address same = null;
Address similar = null;
for (Address from : data.draft.from) {
if (same == null && recognized.sameAddress(from))
same = from;
if (similar == null && recognized.similarAddress(from))
similar = from;
}
preferred = (same == null ? similar : same);
}
}
if (preferred == null)
preferred = data.draft.from[0];
String from = ((InternetAddress) preferred).getAddress();
if (from != null && from.contains("@"))
data.draft.extra = from.substring(0, from.indexOf("@"));
}