Check for empty sender on block sender rule

pull/183/head
M66B 5 years ago
parent 97bbb52df3
commit 410af9dce0

@ -609,9 +609,15 @@ public class EntityRule {
}
static EntityRule blockSender(Context context, EntityMessage message, EntityFolder junk, boolean block_domain, List<String> whitelist) throws JSONException {
if (message.from == null || message.from.length == 0)
return null;
String sender = ((InternetAddress) message.from[0]).getAddress();
String name = MessageHelper.formatAddresses(new Address[]{message.from[0]});
if (TextUtils.isEmpty(sender))
return null;
if (block_domain) {
int at = sender.indexOf('@');
if (at > 0) {

@ -6330,10 +6330,10 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
EntityOperation.queue(context, message, EntityOperation.MOVE, junk.id);
if ((block_sender || block_domain) &&
(message.from != null && message.from.length > 0)) {
if (block_sender || block_domain) {
EntityRule rule = EntityRule.blockSender(context, message, junk, block_domain, whitelist);
rule.id = db.rule().insertRule(rule);
if (rule != null)
rule.id = db.rule().insertRule(rule);
}

@ -262,7 +262,8 @@ public class ServiceUI extends IntentService {
if (block_sender) {
EntityRule rule = EntityRule.blockSender(this, message, junk, false, whitelist);
rule.id = db.rule().insertRule(rule);
if (rule != null)
rule.id = db.rule().insertRule(rule);
}
db.setTransactionSuccessful();

Loading…
Cancel
Save