mirror of https://github.com/M66B/FairEmail.git
Prevent replying to self
This commit is contained in:
parent
3eea0c09c4
commit
03c3934aa5
9
FAQ.md
9
FAQ.md
|
@ -678,12 +678,11 @@ Note that this is independent of receiving messages.
|
|||
<a name="faq34"></a>
|
||||
**(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
|
||||
1. *To* header address
|
||||
1. *Cc* header address
|
||||
1. *From* header address
|
||||
The matched address will be shown as *via* in the addresses section.
|
||||
|
||||
Matched identities can be used to color code messages.
|
||||
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.setText(bcc);
|
||||
|
||||
tvIdentityTitle.setVisibility(show_addresses && debug && via != null ? View.VISIBLE : View.GONE);
|
||||
tvIdentity.setVisibility(show_addresses && debug && via != null ? View.VISIBLE : View.GONE);
|
||||
tvIdentityTitle.setVisibility(show_addresses && 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}));
|
||||
|
||||
tvTimeExTitle.setVisibility(show_addresses ? View.VISIBLE : View.GONE);
|
||||
|
|
|
@ -72,7 +72,6 @@ import javax.mail.Session;
|
|||
import javax.mail.Store;
|
||||
import javax.mail.StoreClosedException;
|
||||
import javax.mail.UIDFolder;
|
||||
import javax.mail.internet.AddressException;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import javax.mail.search.ComparisonTerm;
|
||||
|
@ -1096,23 +1095,22 @@ class Core {
|
|||
Address[] froms = helper.getFrom();
|
||||
Address[] tos = helper.getTo();
|
||||
Address[] ccs = helper.getCc();
|
||||
String delivered = helper.getDeliveredTo();
|
||||
|
||||
// Build ordered list of addresses
|
||||
List<Address> addresses = new ArrayList<>();
|
||||
if (delivered != null)
|
||||
try {
|
||||
addresses.add(new InternetAddress(delivered));
|
||||
} catch (AddressException ex) {
|
||||
// Local address contains control or whitespace in string ``mailing list someone@example.org''
|
||||
Log.w(ex);
|
||||
if (folder.isOutgoing()) {
|
||||
if (froms != null)
|
||||
addresses.addAll(Arrays.asList(froms));
|
||||
} else {
|
||||
if (tos != null)
|
||||
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
|
||||
EntityIdentity identity = null;
|
||||
|
@ -1144,7 +1142,8 @@ class Core {
|
|||
|
||||
message.references = TextUtils.join(" ", helper.getReferences());
|
||||
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.from = froms;
|
||||
message.to = tos;
|
||||
|
|
|
@ -1717,28 +1717,19 @@ public class FragmentCompose extends FragmentBase {
|
|||
draft.inreplyto = ref.msgid;
|
||||
draft.thread = ref.thread;
|
||||
|
||||
// Special case
|
||||
if (BuildConfig.DEBUG) {
|
||||
String from = null;
|
||||
String to = null;
|
||||
String delivered = Helper.canonicalAddress(ref.deliveredto);
|
||||
String me = Helper.canonicalAddress(Helper.myAddress().getAddress());
|
||||
// Prevent replying to self
|
||||
String from = null;
|
||||
String via = null;
|
||||
if (ref.from != null && ref.from.length > 0)
|
||||
from = Helper.canonicalAddress(((InternetAddress) ref.from[0]).getAddress());
|
||||
if (ref.identity != null) {
|
||||
EntityIdentity v = db.identity().getIdentity(ref.identity);
|
||||
via = Helper.canonicalAddress(v.email);
|
||||
}
|
||||
|
||||
if (ref.from != null && ref.from.length > 0)
|
||||
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 (delivered.equals(me) && from != null && from.equals(me)) {
|
||||
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;
|
||||
}
|
||||
if (from != null && from.equals(via)) {
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue