Revert "Fixed reply to self"

This reverts commit 98a058775b.
pull/184/head
M66B 5 years ago
parent cb147b960e
commit 0fbdc56769

@ -208,36 +208,24 @@ public class EntityMessage implements Serializable {
return "<" + UUID.randomUUID() + "@" + domain + '>'; return "<" + UUID.randomUUID() + "@" + domain + '>';
} }
List<Address> replyOthers(List<TupleIdentityEx> identities, long account) { boolean replySelf(List<TupleIdentityEx> identities, long account) {
List<Address> others = new ArrayList<>();
Address[] senders = (reply == null || reply.length == 0 ? from : reply); Address[] senders = (reply == null || reply.length == 0 ? from : reply);
if (identities != null && senders != null) if (identities != null && senders != null)
for (Address sender : senders) { for (Address sender : senders)
boolean self = false;
for (TupleIdentityEx identity : identities) for (TupleIdentityEx identity : identities)
if (identity.account == account && if (identity.account == account &&
identity.self && identity.self &&
identity.similarAddress(sender)) { identity.similarAddress(sender))
self = true; return true;
break;
}
if (!self)
others.add(sender);
}
return others; return false;
} }
Address[] getAllRecipients(List<TupleIdentityEx> identities, long account) { Address[] getAllRecipients(List<TupleIdentityEx> identities, long account) {
List<Address> addresses = new ArrayList<>(); List<Address> addresses = new ArrayList<>();
List<Address> others = replyOthers(identities, account); if (to != null && !replySelf(identities, account))
if (others.size() > 0)
addresses.addAll(others);
else {
if (to != null)
addresses.addAll(Arrays.asList(to)); addresses.addAll(Arrays.asList(to));
}
if (cc != null) if (cc != null)
addresses.addAll(Arrays.asList(cc)); addresses.addAll(Arrays.asList(cc));

@ -3151,11 +3151,8 @@ public class FragmentCompose extends FragmentBase {
break; break;
} }
Address[] refto = null; Address[] refto = (ref == null ? null
if (ref != null) { : ref.replySelf(data.identities, ref.account) ? ref.from : ref.to);
List<Address> others = ref.replyOthers(data.identities, ref.account);
refto = (others.size() == 0 ? ref.to : others.toArray(new Address[0]));
}
if (refto != null && refto.length > 0) { if (refto != null && refto.length > 0) {
if (selected == null) if (selected == null)
for (Address sender : refto) for (Address sender : refto)
@ -3319,13 +3316,20 @@ public class FragmentCompose extends FragmentBase {
data.draft.to = ref.receipt_to; data.draft.to = ref.receipt_to;
else { else {
// Prevent replying to self // Prevent replying to self
List<Address> others = ref.replyOthers(data.identities, ref.account); if (ref.replySelf(data.identities, ref.account)) {
if (others.size() == 0) {
data.draft.from = ref.from; data.draft.from = ref.from;
data.draft.to = ref.to; List<Address> tos = new ArrayList<>();
if (ref.to != null)
for (Address to : ref.to)
for (EntityIdentity identity : data.identities)
if (!Objects.equals(identity.account, ref.account) ||
!identity.self ||
!identity.similarAddress(to))
tos.add(to);
data.draft.to = (tos.size() == 0 ? null : tos.toArray(new Address[0]));
} else { } else {
data.draft.from = ref.to; data.draft.from = ref.to;
data.draft.to = others.toArray(new Address[0]); data.draft.to = (ref.reply == null || ref.reply.length == 0 ? ref.from : ref.reply);
} }
if (data.draft.from != null && data.draft.from.length > 0) { if (data.draft.from != null && data.draft.from.length > 0) {

@ -2193,8 +2193,10 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
if (data.identities == null) if (data.identities == null)
data.identities = new ArrayList<>(); data.identities = new ArrayList<>();
List<Address> others = message.replyOthers(data.identities, message.account); final Address[] to =
final Address[] to = (others.size() == 0 ? message.to : others.toArray(new Address[0])); message.replySelf(data.identities, message.account)
? message.to
: (message.reply == null || message.reply.length == 0 ? message.from : message.reply);
Address[] recipients = message.getAllRecipients(data.identities, message.account); Address[] recipients = message.getAllRecipients(data.identities, message.account);

Loading…
Cancel
Save