Skip suggesting no-reply addresses of received messages

pull/212/head
M66B 2 years ago
parent 6acb252a85
commit 6997965336

@ -1148,7 +1148,9 @@ public class FragmentCompose extends FragmentBase {
if (suggest_sent)
items.addAll(db.contact().searchContacts(null, EntityContact.TYPE_TO, wildcard));
if (suggest_received)
items.addAll(db.contact().searchContacts(null, EntityContact.TYPE_FROM, wildcard));
for (EntityContact item : db.contact().searchContacts(null, EntityContact.TYPE_FROM, wildcard))
if (!MessageHelper.isNoReply(item.email))
items.add(item);
for (EntityContact item : items) {
EntityContact existing = map.get(item.email);
if (existing == null)

@ -5284,21 +5284,27 @@ public class MessageHelper {
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;
}
if (isNoReply(email))
return true;
}
return false;
}
static boolean isNoReply(String email) {
String username = UriHelper.getEmailUser(email);
if (!TextUtils.isEmpty(username)) {
username = username.toLowerCase(Locale.ROOT);
for (String value : DO_NOT_REPLY)
if (username.contains(value))
return true;
}
String domain = UriHelper.getEmailDomain(email);
if (!TextUtils.isEmpty(domain)) {
domain = domain.toLowerCase(Locale.ROOT);
for (String value : DO_NOT_REPLY)
if (domain.startsWith(value))
return true;
}
return false;

Loading…
Cancel
Save