mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-31 20:25:38 +00:00
Check for no-reply domains
This commit is contained in:
parent
90c68a979b
commit
dab843727b
2 changed files with 34 additions and 15 deletions
|
@ -328,10 +328,6 @@ public class FragmentCompose extends FragmentBase {
|
|||
|
||||
private static ExecutorService executor = Helper.getBackgroundExecutor(1, "encrypt");
|
||||
|
||||
private static final List<String> DO_NOT_REPLY = Collections.unmodifiableList(Arrays.asList(
|
||||
"noreply", "no.reply", "no-reply", "do-not-reply"
|
||||
));
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -5811,18 +5807,11 @@ public class FragmentCompose extends FragmentBase {
|
|||
recipients.addAll(Arrays.asList(draft.bcc));
|
||||
|
||||
boolean noreply = false;
|
||||
for (Address recipient : recipients) {
|
||||
String email = ((InternetAddress) recipient).getAddress();
|
||||
String username = UriHelper.getEmailUser(email);
|
||||
if (!TextUtils.isEmpty(username)) {
|
||||
username = username.toLowerCase(Locale.ROOT);
|
||||
for (String value : DO_NOT_REPLY)
|
||||
if (username.contains(value)) {
|
||||
noreply = true;
|
||||
break;
|
||||
}
|
||||
for (Address recipient : recipients)
|
||||
if (MessageHelper.isNoReply(recipient)) {
|
||||
noreply = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
args.putBoolean("remind_noreply", noreply);
|
||||
|
||||
if (identity != null && !TextUtils.isEmpty(identity.internal)) {
|
||||
|
|
|
@ -145,6 +145,13 @@ public class MessageHelper {
|
|||
StandardCharsets.UTF_16LE
|
||||
));
|
||||
|
||||
private static final List<String> DO_NOT_REPLY = Collections.unmodifiableList(Arrays.asList(
|
||||
"noreply",
|
||||
"no.reply",
|
||||
"no-reply",
|
||||
"do-not-reply"
|
||||
));
|
||||
|
||||
static final String FLAG_FORWARDED = "$Forwarded";
|
||||
static final String FLAG_JUNK = "$Junk";
|
||||
static final String FLAG_NOT_JUNK = "$NotJunk";
|
||||
|
@ -3216,6 +3223,29 @@ public class MessageHelper {
|
|||
return false;
|
||||
}
|
||||
|
||||
static boolean isNoReply(Address address) {
|
||||
if (address instanceof InternetAddress) {
|
||||
String email = ((InternetAddress) address).getAddress();
|
||||
String username = UriHelper.getEmailUser(email);
|
||||
String domain = UriHelper.getEmailDomain(email);
|
||||
|
||||
if (!TextUtils.isEmpty(username)) {
|
||||
username = username.toLowerCase(Locale.ROOT);
|
||||
for (String value : DO_NOT_REPLY)
|
||||
if (username.contains(value))
|
||||
return true;
|
||||
}
|
||||
if (!TextUtils.isEmpty(domain)) {
|
||||
domain = domain.toLowerCase(Locale.ROOT);
|
||||
for (String value : DO_NOT_REPLY)
|
||||
if (domain.startsWith(value))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static boolean equalEmail(Address a1, Address a2) {
|
||||
String email1 = ((InternetAddress) a1).getAddress();
|
||||
String email2 = ((InternetAddress) a2).getAddress();
|
||||
|
|
Loading…
Reference in a new issue