mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-01 14:46:31 +02:00
Prevent blocking common domain names
This commit is contained in:
@@ -540,14 +540,23 @@ public class EntityRule {
|
||||
return cal;
|
||||
}
|
||||
|
||||
static EntityRule blockSender(Context context, EntityMessage message, EntityFolder junk, boolean block_domain) throws JSONException {
|
||||
static EntityRule blockSender(Context context, EntityMessage message, EntityFolder junk, boolean block_domain, List<String> whitelist) throws JSONException {
|
||||
String sender = ((InternetAddress) message.from[0]).getAddress();
|
||||
String name = MessageHelper.formatAddresses(new Address[]{message.from[0]});
|
||||
|
||||
if (block_domain) {
|
||||
int at = sender.indexOf('@');
|
||||
if (at > 0)
|
||||
sender = sender.substring(at);
|
||||
if (at > 0) {
|
||||
boolean whitelisted = false;
|
||||
String domain = sender.substring(at + 1);
|
||||
for (String d : whitelist)
|
||||
if (domain.matches(d)) {
|
||||
whitelisted = true;
|
||||
break;
|
||||
}
|
||||
if (!whitelisted)
|
||||
sender = '@' + domain;
|
||||
}
|
||||
}
|
||||
|
||||
JSONObject jsender = new JSONObject();
|
||||
|
||||
Reference in New Issue
Block a user