mirror of https://github.com/M66B/FairEmail.git
Check self/cc using all identities
This commit is contained in:
parent
cc15eda190
commit
1790a15fdf
|
@ -2168,26 +2168,22 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
Bundle args = new Bundle();
|
||||
args.putSerializable("message", message);
|
||||
|
||||
new SimpleTask<EntityIdentity>() {
|
||||
new SimpleTask<List<TupleIdentityEx>>() {
|
||||
@Override
|
||||
protected EntityIdentity onExecute(Context context, Bundle args) {
|
||||
TupleMessageEx message = (TupleMessageEx) args.getSerializable("message");
|
||||
if (message.identity == null)
|
||||
return null;
|
||||
|
||||
protected List<TupleIdentityEx> onExecute(Context context, Bundle args) {
|
||||
DB db = DB.getInstance(context);
|
||||
return db.identity().getIdentity(message.identity);
|
||||
return db.identity().getComposableIdentities(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onExecuted(Bundle args, EntityIdentity identity) {
|
||||
protected void onExecuted(Bundle args, List<TupleIdentityEx> identities) {
|
||||
TupleMessageEx message = (TupleMessageEx) args.getSerializable("message");
|
||||
|
||||
TupleMessageEx amessage = getMessage();
|
||||
if (amessage == null || !amessage.id.equals(message.id))
|
||||
return;
|
||||
|
||||
Address[] recipients = message.getAllRecipients(identity);
|
||||
Address[] recipients = message.getAllRecipients(identities);
|
||||
|
||||
View anchor = bnvActions.findViewById(R.id.action_reply);
|
||||
PopupMenuLifecycle popupMenu = new PopupMenuLifecycle(context, powner, anchor);
|
||||
|
|
|
@ -162,31 +162,32 @@ public class EntityMessage implements Serializable {
|
|||
return "<" + UUID.randomUUID() + "@localhost" + '>';
|
||||
}
|
||||
|
||||
boolean replySelf(EntityIdentity identity) {
|
||||
if (identity == null)
|
||||
return false;
|
||||
|
||||
boolean replySelf(List<TupleIdentityEx> identities) {
|
||||
if (identities != null) {
|
||||
Address[] senders = (reply == null || reply.length == 0 ? from : reply);
|
||||
if (senders != null)
|
||||
for (Address sender : senders)
|
||||
for (TupleIdentityEx identity : identities)
|
||||
if (identity.similarAddress(sender))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Address[] getAllRecipients(EntityIdentity identity) {
|
||||
Address[] getAllRecipients(List<TupleIdentityEx> identities) {
|
||||
List<Address> addresses = new ArrayList<>();
|
||||
|
||||
if (to != null && !replySelf(identity))
|
||||
if (to != null && !replySelf(identities))
|
||||
addresses.addAll(Arrays.asList(to));
|
||||
|
||||
if (cc != null)
|
||||
addresses.addAll(Arrays.asList(cc));
|
||||
|
||||
// Filter self
|
||||
if (identity != null)
|
||||
if (identities != null)
|
||||
for (Address address : new ArrayList<>(addresses))
|
||||
for (TupleIdentityEx identity : identities)
|
||||
if (identity.similarAddress(address))
|
||||
addresses.remove(address);
|
||||
|
||||
|
|
|
@ -2096,17 +2096,13 @@ public class FragmentCompose extends FragmentBase {
|
|||
data.draft.inreplyto = ref.msgid;
|
||||
data.draft.thread = ref.thread;
|
||||
|
||||
EntityIdentity ridentity = null;
|
||||
if (ref.identity != null)
|
||||
ridentity = db.identity().getIdentity(ref.identity);
|
||||
|
||||
if ("list".equals(action) && ref.list_post != null)
|
||||
data.draft.to = ref.list_post;
|
||||
else if ("receipt".equals(action) && ref.receipt_to != null)
|
||||
data.draft.to = ref.receipt_to;
|
||||
else {
|
||||
// Prevent replying to self
|
||||
if (ref.replySelf(ridentity)) {
|
||||
if (ref.replySelf(data.identities)) {
|
||||
data.draft.from = ref.from;
|
||||
data.draft.to = ref.to;
|
||||
} else {
|
||||
|
@ -2116,7 +2112,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
}
|
||||
|
||||
if ("reply_all".equals(action))
|
||||
data.draft.cc = ref.getAllRecipients(ridentity);
|
||||
data.draft.cc = ref.getAllRecipients(data.identities);
|
||||
else if ("receipt".equals(action))
|
||||
data.draft.receipt_request = true;
|
||||
|
||||
|
|
Loading…
Reference in New Issue