mirror of https://github.com/M66B/FairEmail.git
Refactoring
This commit is contained in:
parent
121c89abbd
commit
09ace5e05a
|
@ -804,9 +804,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
try {
|
||||
via = new InternetAddress(message.identityEmail, message.identityName);
|
||||
if (message.to != null) {
|
||||
String v = Helper.canonicalAddress(via.getAddress());
|
||||
String v = MessageHelper.canonicalAddress(via.getAddress());
|
||||
for (Address t : message.to) {
|
||||
if (v.equals(Helper.canonicalAddress(((InternetAddress) t).getAddress()))) {
|
||||
if (v.equals(MessageHelper.canonicalAddress(((InternetAddress) t).getAddress()))) {
|
||||
self = true;
|
||||
break;
|
||||
}
|
||||
|
@ -1197,7 +1197,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
else {
|
||||
String from = ((InternetAddress) message.from[0]).getAddress();
|
||||
EntityIdentity identity = db.identity().getIdentity(message.identity);
|
||||
outgoing = Helper.canonicalAddress(identity.email).equals(Helper.canonicalAddress(from));
|
||||
outgoing = MessageHelper.canonicalAddress(identity.email)
|
||||
.equals(MessageHelper.canonicalAddress(from));
|
||||
}
|
||||
|
||||
return (outgoing
|
||||
|
|
|
@ -1268,7 +1268,7 @@ class Core {
|
|||
if (!TextUtils.isEmpty(email)) {
|
||||
identity = db.identity().getIdentity(folder.account, email);
|
||||
if (identity == null) {
|
||||
String canonical = Helper.canonicalAddress(email);
|
||||
String canonical = MessageHelper.canonicalAddress(email);
|
||||
if (!canonical.equals(email))
|
||||
identity = db.identity().getIdentity(folder.account, canonical);
|
||||
}
|
||||
|
@ -1496,7 +1496,7 @@ class Core {
|
|||
boolean me = true;
|
||||
for (Address reply : recipients) {
|
||||
String email = ((InternetAddress) reply).getAddress();
|
||||
String canonical = Helper.canonicalAddress(email);
|
||||
String canonical = MessageHelper.canonicalAddress(email);
|
||||
if (!TextUtils.isEmpty(email) &&
|
||||
db.identity().getIdentity(folder.account, email) == null &&
|
||||
(canonical.equals(email) ||
|
||||
|
|
|
@ -2035,10 +2035,10 @@ public class FragmentCompose extends FragmentBase {
|
|||
String via = null;
|
||||
Address[] recipient = (ref.reply == null || ref.reply.length == 0 ? ref.from : ref.reply);
|
||||
if (recipient != null && recipient.length > 0)
|
||||
to = Helper.canonicalAddress(((InternetAddress) recipient[0]).getAddress());
|
||||
to = MessageHelper.canonicalAddress(((InternetAddress) recipient[0]).getAddress());
|
||||
if (ref.identity != null) {
|
||||
EntityIdentity v = db.identity().getIdentity(ref.identity);
|
||||
via = Helper.canonicalAddress(v.email);
|
||||
via = MessageHelper.canonicalAddress(v.email);
|
||||
}
|
||||
|
||||
if (to != null && to.equals(via)) {
|
||||
|
@ -2058,10 +2058,10 @@ public class FragmentCompose extends FragmentBase {
|
|||
if (ref.cc != null)
|
||||
addresses.addAll(Arrays.asList(ref.cc));
|
||||
for (Address address : new ArrayList<>(addresses)) {
|
||||
String cc = Helper.canonicalAddress(((InternetAddress) address).getAddress());
|
||||
String cc = MessageHelper.canonicalAddress(((InternetAddress) address).getAddress());
|
||||
List<TupleIdentityEx> identities = db.identity().getComposableIdentities(ref.account);
|
||||
for (EntityIdentity identity : identities) {
|
||||
String email = Helper.canonicalAddress(identity.email);
|
||||
String email = MessageHelper.canonicalAddress(identity.email);
|
||||
if (cc.equals(email))
|
||||
addresses.remove(address);
|
||||
}
|
||||
|
@ -2120,9 +2120,9 @@ public class FragmentCompose extends FragmentBase {
|
|||
do {
|
||||
String from = null;
|
||||
if (iindex >= 0)
|
||||
from = Helper.canonicalAddress(((InternetAddress) draft.from[iindex]).getAddress());
|
||||
from = MessageHelper.canonicalAddress(((InternetAddress) draft.from[iindex]).getAddress());
|
||||
for (EntityIdentity identity : identities) {
|
||||
String email = Helper.canonicalAddress(identity.email);
|
||||
String email = MessageHelper.canonicalAddress(identity.email);
|
||||
if (email.equals(from)) {
|
||||
draft.identity = identity.id;
|
||||
draft.from = new InternetAddress[]{new InternetAddress(identity.email, identity.name)};
|
||||
|
|
|
@ -787,16 +787,6 @@ public class Helper {
|
|||
return new InternetAddress("marcel+fairemail@faircode.eu", "FairCode");
|
||||
}
|
||||
|
||||
static String canonicalAddress(String address) {
|
||||
String[] a = address.split("@");
|
||||
if (a.length > 0) {
|
||||
String[] extra = a[0].split("\\+");
|
||||
if (extra.length > 0)
|
||||
a[0] = extra[0];
|
||||
}
|
||||
return TextUtils.join("@", a).toLowerCase();
|
||||
}
|
||||
|
||||
static void writeText(File file, String content) throws IOException {
|
||||
try (BufferedWriter out = new BufferedWriter(new FileWriter(file))) {
|
||||
out.write(content == null ? "" : content);
|
||||
|
|
|
@ -731,6 +731,16 @@ public class MessageHelper {
|
|||
return TextUtils.join(", ", formatted);
|
||||
}
|
||||
|
||||
static String canonicalAddress(String address) {
|
||||
String[] a = address.split("@");
|
||||
if (a.length > 0) {
|
||||
String[] extra = a[0].split("\\+");
|
||||
if (extra.length > 0)
|
||||
a[0] = extra[0];
|
||||
}
|
||||
return TextUtils.join("@", a).toLowerCase();
|
||||
}
|
||||
|
||||
static String decodeMime(String text) {
|
||||
if (text == null)
|
||||
return null;
|
||||
|
|
Loading…
Reference in New Issue