From 0fbdc56769d98caaff151eaf3d0d561ce9e93634 Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 22 Jul 2020 07:24:06 +0200 Subject: [PATCH] Revert "Fixed reply to self" This reverts commit 98a058775bab5b336ea220fa2c946a915bb35cab. --- .../java/eu/faircode/email/EntityMessage.java | 26 +++++-------------- .../eu/faircode/email/FragmentCompose.java | 22 +++++++++------- .../eu/faircode/email/FragmentMessages.java | 6 +++-- 3 files changed, 24 insertions(+), 30 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/EntityMessage.java b/app/src/main/java/eu/faircode/email/EntityMessage.java index ea0c69b978..5c8865c98c 100644 --- a/app/src/main/java/eu/faircode/email/EntityMessage.java +++ b/app/src/main/java/eu/faircode/email/EntityMessage.java @@ -208,36 +208,24 @@ public class EntityMessage implements Serializable { return "<" + UUID.randomUUID() + "@" + domain + '>'; } - List
replyOthers(List identities, long account) { - List
others = new ArrayList<>(); + boolean replySelf(List identities, long account) { Address[] senders = (reply == null || reply.length == 0 ? from : reply); if (identities != null && senders != null) - for (Address sender : senders) { - boolean self = false; + for (Address sender : senders) for (TupleIdentityEx identity : identities) if (identity.account == account && identity.self && - identity.similarAddress(sender)) { - self = true; - break; - } - if (!self) - others.add(sender); - } + identity.similarAddress(sender)) + return true; - return others; + return false; } Address[] getAllRecipients(List identities, long account) { List
addresses = new ArrayList<>(); - List
others = replyOthers(identities, account); - if (others.size() > 0) - addresses.addAll(others); - else { - if (to != null) - addresses.addAll(Arrays.asList(to)); - } + if (to != null && !replySelf(identities, account)) + addresses.addAll(Arrays.asList(to)); if (cc != null) addresses.addAll(Arrays.asList(cc)); diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index 2d7bd2af9a..117f30dcc1 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -3151,11 +3151,8 @@ public class FragmentCompose extends FragmentBase { break; } - Address[] refto = null; - if (ref != null) { - List
others = ref.replyOthers(data.identities, ref.account); - refto = (others.size() == 0 ? ref.to : others.toArray(new Address[0])); - } + Address[] refto = (ref == null ? null + : ref.replySelf(data.identities, ref.account) ? ref.from : ref.to); if (refto != null && refto.length > 0) { if (selected == null) for (Address sender : refto) @@ -3319,13 +3316,20 @@ public class FragmentCompose extends FragmentBase { data.draft.to = ref.receipt_to; else { // Prevent replying to self - List
others = ref.replyOthers(data.identities, ref.account); - if (others.size() == 0) { + if (ref.replySelf(data.identities, ref.account)) { data.draft.from = ref.from; - data.draft.to = ref.to; + List
tos = new ArrayList<>(); + if (ref.to != null) + for (Address to : ref.to) + for (EntityIdentity identity : data.identities) + if (!Objects.equals(identity.account, ref.account) || + !identity.self || + !identity.similarAddress(to)) + tos.add(to); + data.draft.to = (tos.size() == 0 ? null : tos.toArray(new Address[0])); } else { data.draft.from = ref.to; - data.draft.to = others.toArray(new Address[0]); + data.draft.to = (ref.reply == null || ref.reply.length == 0 ? ref.from : ref.reply); } if (data.draft.from != null && data.draft.from.length > 0) { diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index bd28b1765b..a00270990e 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -2193,8 +2193,10 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. if (data.identities == null) data.identities = new ArrayList<>(); - List
others = message.replyOthers(data.identities, message.account); - final Address[] to = (others.size() == 0 ? message.to : others.toArray(new Address[0])); + final Address[] to = + message.replySelf(data.identities, message.account) + ? message.to + : (message.reply == null || message.reply.length == 0 ? message.from : message.reply); Address[] recipients = message.getAllRecipients(data.identities, message.account);