From 826c59fcec5c5325fdfb26fb9c4aec67761021df Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 1 Apr 2019 07:58:20 +0200 Subject: [PATCH] Prevent replying to self --- app/src/main/java/eu/faircode/email/FragmentCompose.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index f04be63b80..bf6aa7ea36 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -1718,16 +1718,17 @@ public class FragmentCompose extends FragmentBase { draft.thread = ref.thread; // Prevent replying to self - String from = null; + String to = null; String via = null; - if (ref.from != null && ref.from.length > 0) - from = Helper.canonicalAddress(((InternetAddress) ref.from[0]).getAddress()); + Address[] recipient = (ref.reply == null || ref.reply.length == 0 ? ref.from : ref.reply); + if (recipient != null && recipient.length > 0) + to = Helper.canonicalAddress(((InternetAddress) recipient[0]).getAddress()); if (ref.identity != null) { EntityIdentity v = db.identity().getIdentity(ref.identity); via = Helper.canonicalAddress(v.email); } - if (from != null && from.equals(via)) { + if (to != null && to.equals(via)) { draft.to = ref.to; draft.from = ref.from; } else {