Prevent replying to self

pull/153/head
M66B 6 years ago
parent 3eea0c09c4
commit 03c3934aa5

@ -678,12 +678,11 @@ Note that this is independent of receiving messages.
<a name="faq34"></a> <a name="faq34"></a>
**(34) How are identities matched?** **(34) How are identities matched?**
Identities are matched on e-mail address in this order: Identities are as expected matched by account.
For incoming messages the *to* and *cc* address will be checked and for outgoing messages the *from* addresses will be checked.
Archived messages will be considered as incoming messages, but additionally the *from* address will be checked.
1. *Delivered-To* header address The matched address will be shown as *via* in the addresses section.
1. *To* header address
1. *Cc* header address
1. *From* header address
Matched identities can be used to color code messages. Matched identities can be used to color code messages.
The identity color takes precedence over the account color. The identity color takes precedence over the account color.

@ -851,8 +851,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
tvBcc.setVisibility(show_addresses && !TextUtils.isEmpty(bcc) ? View.VISIBLE : View.GONE); tvBcc.setVisibility(show_addresses && !TextUtils.isEmpty(bcc) ? View.VISIBLE : View.GONE);
tvBcc.setText(bcc); tvBcc.setText(bcc);
tvIdentityTitle.setVisibility(show_addresses && debug && via != null ? View.VISIBLE : View.GONE); tvIdentityTitle.setVisibility(show_addresses && via != null ? View.VISIBLE : View.GONE);
tvIdentity.setVisibility(show_addresses && debug && via != null ? View.VISIBLE : View.GONE); tvIdentity.setVisibility(show_addresses && via != null ? View.VISIBLE : View.GONE);
tvIdentity.setText(via == null ? null : MessageHelper.formatAddresses(new Address[]{via})); tvIdentity.setText(via == null ? null : MessageHelper.formatAddresses(new Address[]{via}));
tvTimeExTitle.setVisibility(show_addresses ? View.VISIBLE : View.GONE); tvTimeExTitle.setVisibility(show_addresses ? View.VISIBLE : View.GONE);

@ -72,7 +72,6 @@ import javax.mail.Session;
import javax.mail.Store; import javax.mail.Store;
import javax.mail.StoreClosedException; import javax.mail.StoreClosedException;
import javax.mail.UIDFolder; import javax.mail.UIDFolder;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress; import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMessage;
import javax.mail.search.ComparisonTerm; import javax.mail.search.ComparisonTerm;
@ -1096,23 +1095,22 @@ class Core {
Address[] froms = helper.getFrom(); Address[] froms = helper.getFrom();
Address[] tos = helper.getTo(); Address[] tos = helper.getTo();
Address[] ccs = helper.getCc(); Address[] ccs = helper.getCc();
String delivered = helper.getDeliveredTo();
// Build ordered list of addresses // Build ordered list of addresses
List<Address> addresses = new ArrayList<>(); List<Address> addresses = new ArrayList<>();
if (delivered != null) if (folder.isOutgoing()) {
try { if (froms != null)
addresses.add(new InternetAddress(delivered)); addresses.addAll(Arrays.asList(froms));
} catch (AddressException ex) { } else {
// Local address contains control or whitespace in string ``mailing list someone@example.org'' if (tos != null)
Log.w(ex); addresses.addAll(Arrays.asList(tos));
if (ccs != null)
addresses.addAll(Arrays.asList(ccs));
if (EntityFolder.ARCHIVE.equals(folder.type)) {
if (froms != null)
addresses.addAll(Arrays.asList(froms));
} }
if (tos != null) }
addresses.addAll(Arrays.asList(tos));
if (ccs != null)
addresses.addAll(Arrays.asList(ccs));
if (froms != null)
addresses.addAll(Arrays.asList(froms));
// Search for matching identity // Search for matching identity
EntityIdentity identity = null; EntityIdentity identity = null;
@ -1144,7 +1142,8 @@ class Core {
message.references = TextUtils.join(" ", helper.getReferences()); message.references = TextUtils.join(" ", helper.getReferences());
message.inreplyto = helper.getInReplyTo(); message.inreplyto = helper.getInReplyTo();
message.deliveredto = delivered; // Local address contains control or whitespace in string ``mailing list someone@example.org''
message.deliveredto = helper.getDeliveredTo();
message.thread = helper.getThreadId(context, account.id, uid); message.thread = helper.getThreadId(context, account.id, uid);
message.from = froms; message.from = froms;
message.to = tos; message.to = tos;

@ -1717,28 +1717,19 @@ public class FragmentCompose extends FragmentBase {
draft.inreplyto = ref.msgid; draft.inreplyto = ref.msgid;
draft.thread = ref.thread; draft.thread = ref.thread;
// Special case // Prevent replying to self
if (BuildConfig.DEBUG) { String from = null;
String from = null; String via = null;
String to = null; if (ref.from != null && ref.from.length > 0)
String delivered = Helper.canonicalAddress(ref.deliveredto); from = Helper.canonicalAddress(((InternetAddress) ref.from[0]).getAddress());
String me = Helper.canonicalAddress(Helper.myAddress().getAddress()); if (ref.identity != null) {
EntityIdentity v = db.identity().getIdentity(ref.identity);
if (ref.from != null && ref.from.length > 0) via = Helper.canonicalAddress(v.email);
from = Helper.canonicalAddress(((InternetAddress) ref.from[0]).getAddress()); }
if (ref.to != null && ref.to.length > 0)
to = Helper.canonicalAddress(((InternetAddress) ref.to[0]).getAddress()); if (from != null && from.equals(via)) {
draft.to = ref.to;
if (delivered.equals(me) && from != null && from.equals(me)) { draft.from = ref.from;
if (to != null && to.equals(me))
draft.to = ref.reply;
else
draft.to = ref.to;
draft.from = ref.from;
} else {
draft.to = (ref.reply == null || ref.reply.length == 0 ? ref.from : ref.reply);
draft.from = ref.to;
}
} else { } else {
draft.to = (ref.reply == null || ref.reply.length == 0 ? ref.from : ref.reply); draft.to = (ref.reply == null || ref.reply.length == 0 ? ref.from : ref.reply);
draft.from = ref.to; draft.from = ref.to;

Loading…
Cancel
Save