1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-30 19:56:10 +00:00

Refactoring

This commit is contained in:
M66B 2022-01-30 17:26:07 +01:00
parent 9279435e06
commit 86c26e895b
2 changed files with 11 additions and 10 deletions

View file

@ -1019,6 +1019,7 @@ public class EntityRule {
if (message.from == null)
return rules;
List<String> domains = new ArrayList<>();
for (Address from : message.from) {
String sender = ((InternetAddress) from).getAddress();
String name = MessageHelper.formatAddresses(new Address[]{from});
@ -1029,10 +1030,11 @@ public class EntityRule {
boolean regex = false;
if (block_domain) {
int at = sender.indexOf('@');
if (at > 0) {
String domain = UriHelper.getEmailDomain(sender);
if (!TextUtils.isEmpty(domain) && !domains.contains(domain)) {
domains.add(domain);
regex = true;
sender = ".*@.*" + Pattern.quote(sender.substring(at + 1)) + ".*";
sender = ".*@.*" + Pattern.quote(domain) + ".*";
}
}

View file

@ -323,22 +323,21 @@ public class FragmentDialogJunk extends FragmentDialogBase {
}
});
List<String> regex = new ArrayList<>();
regex.addAll(COMMON_DOMAINS);
regex.addAll(EmailProvider.getDomainNames(context));
boolean common = false;
List<String> domains = new ArrayList<>();
if (froms != null)
for (Address from : froms) {
String email = ((InternetAddress) from).getAddress();
int at = (email == null ? -1 : email.indexOf('@'));
String domain = (at < 0 ? null : email.substring(at + 1).toLowerCase(Locale.ROOT));
if (TextUtils.isEmpty(domain))
String domain = UriHelper.getEmailDomain(email);
if (TextUtils.isEmpty(domain) || domains.contains(domain))
continue;
domains.add(domain);
List<String> regex = new ArrayList<>();
regex.addAll(COMMON_DOMAINS);
regex.addAll(EmailProvider.getDomainNames(context));
for (String r : regex)
if (domain.matches(r)) {
common = true;