mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-03 15:46:34 +02:00
Prevent replying to self
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user