Revert "Fixed reply to self"

This reverts commit 98a058775b.
This commit is contained in:
M66B 2020-07-22 07:24:06 +02:00
parent cb147b960e
commit 0fbdc56769
3 changed files with 24 additions and 30 deletions

View File

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

View File

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

View File

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