mirror of https://github.com/M66B/FairEmail.git
Prevent reply to self
This commit is contained in:
parent
763c4201f2
commit
025bbc219c
|
@ -160,10 +160,19 @@ public class EntityMessage implements Serializable {
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean replySelf(String via) {
|
||||||
|
Address[] replying = (reply == null || reply.length == 0 ? from : reply);
|
||||||
|
if (replying == null || replying.length != 1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
String recipient = MessageHelper.canonicalAddress(((InternetAddress) replying[0]).getAddress());
|
||||||
|
return recipient.equals(via);
|
||||||
|
}
|
||||||
|
|
||||||
Address[] getAllRecipients(String via) {
|
Address[] getAllRecipients(String via) {
|
||||||
List<Address> addresses = new ArrayList<>();
|
List<Address> addresses = new ArrayList<>();
|
||||||
|
|
||||||
if (to != null)
|
if (!replySelf(via) && to != null)
|
||||||
addresses.addAll(Arrays.asList(to));
|
addresses.addAll(Arrays.asList(to));
|
||||||
|
|
||||||
if (cc != null)
|
if (cc != null)
|
||||||
|
|
|
@ -2050,16 +2050,11 @@ public class FragmentCompose extends FragmentBase {
|
||||||
draft.to = ref.receipt_to;
|
draft.to = ref.receipt_to;
|
||||||
else {
|
else {
|
||||||
// Prevent replying to self
|
// Prevent replying to self
|
||||||
String to = null;
|
if (ref.replySelf(via)) {
|
||||||
Address[] replying = (ref.reply == null || ref.reply.length == 0 ? ref.from : ref.reply);
|
|
||||||
if (replying != null && replying.length == 1)
|
|
||||||
to = MessageHelper.canonicalAddress(((InternetAddress) replying[0]).getAddress());
|
|
||||||
|
|
||||||
if (to != null && to.equals(via)) {
|
|
||||||
draft.to = ref.to;
|
draft.to = ref.to;
|
||||||
draft.from = ref.from;
|
draft.from = ref.from;
|
||||||
} else
|
} else
|
||||||
draft.to = replying;
|
draft.to = (ref.reply == null || ref.reply.length == 0 ? ref.from : ref.reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("reply_all".equals(action))
|
if ("reply_all".equals(action))
|
||||||
|
|
Loading…
Reference in New Issue