From 57ceca54d753d70cb08cd7be409a53d27ffe3842 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 14 Aug 2018 17:41:21 +0000 Subject: [PATCH] Reply to sender, not to self --- .../java/eu/faircode/email/DaoIdentity.java | 3 +++ .../eu/faircode/email/FragmentCompose.java | 19 ++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/DaoIdentity.java b/app/src/main/java/eu/faircode/email/DaoIdentity.java index 8294fcc2..94dbabc6 100644 --- a/app/src/main/java/eu/faircode/email/DaoIdentity.java +++ b/app/src/main/java/eu/faircode/email/DaoIdentity.java @@ -36,6 +36,9 @@ public interface DaoIdentity { @Query("SELECT * FROM identity WHERE synchronize = :synchronize") LiveData> liveIdentities(boolean synchronize); + @Query("SELECT * FROM identity") + List getIdentities(); + @Query("SELECT * FROM identity WHERE id = :id") EntityIdentity getIdentity(long id); diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index 23e048f1..e815274f 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -540,13 +540,18 @@ public class FragmentCompose extends FragmentEx { if (ref != null) { account = ref.account; - // Reply to sender - EntityFolder rfolder = db.folder().getFolder(ref.folder); - if (EntityFolder.SENT.equals(rfolder.type)) { - Address[] tmp = ref.to; - ref.to = ref.from; - ref.reply = null; - ref.from = tmp; + // Reply to sender, not to known self + if (ref.from != null && ref.from.length == 1) { + // All identities, synchronized or not + List identities = db.identity().getIdentities(); + for (EntityIdentity identity : identities) + if (((InternetAddress) ref.from[0]).getAddress().equals(identity.email)) { + Address[] tmp = ref.to; + ref.to = ref.from; + ref.reply = null; + ref.from = tmp; + break; + } } }