From b19dd4f9bb934202006e1b4fa9608a27758478b3 Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 24 Apr 2019 12:17:32 +0200 Subject: [PATCH] Fixed me check --- app/src/main/java/eu/faircode/email/Core.java | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index 71f2f7ccad..88d2edf7c9 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -1368,25 +1368,26 @@ class Core { Address[] recipients = (type == EntityContact.TYPE_TO ? message.to : (message.reply != null ? message.reply : message.from)); - if (recipients != null) { - // Check if from self - if (type == EntityContact.TYPE_FROM) { - boolean me = true; - for (Address reply : recipients) { - String email = ((InternetAddress) reply).getAddress(); - String canonical = Helper.canonicalAddress(email); - if (!TextUtils.isEmpty(email) && - db.identity().getIdentity(folder.account, email) == null && - (canonical.equals(email) || - db.identity().getIdentity(folder.account, canonical) == null)) { - me = false; - break; - } - } - if (me) - recipients = message.to; - } + // Check if from self + if (type == EntityContact.TYPE_FROM && recipients != null && recipients.length > 0) { + boolean me = true; + for (Address reply : recipients) { + String email = ((InternetAddress) reply).getAddress(); + String canonical = Helper.canonicalAddress(email); + if (!TextUtils.isEmpty(email) && + db.identity().getIdentity(folder.account, email) == null && + (canonical.equals(email) || + db.identity().getIdentity(folder.account, canonical) == null)) { + me = false; + break; + } + } + if (me) + recipients = message.to; + } + + if (recipients != null) { for (Address recipient : recipients) { String email = ((InternetAddress) recipient).getAddress(); String name = ((InternetAddress) recipient).getPersonal();