(
Context context, List<Header> headers, String html,
EntityAccount account, EntityFolder folder, EntityMessage message, boolean browsed,
List<EntityRule> rules)
| 5508 | } |
| 5509 | |
| 5510 | private static void runRules( |
| 5511 | Context context, List<Header> headers, String html, |
| 5512 | EntityAccount account, EntityFolder folder, EntityMessage message, boolean browsed, |
| 5513 | List<EntityRule> rules) { |
| 5514 | |
| 5515 | if (EntityFolder.INBOX.equals(folder.type)) { |
| 5516 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); |
| 5517 | String mnemonic = prefs.getString("wipe_mnemonic", null); |
| 5518 | if (mnemonic != null && message.subject != null && |
| 5519 | message.subject.toLowerCase(Locale.ROOT).contains(mnemonic)) |
| 5520 | Helper.clearAll(context); |
| 5521 | } |
| 5522 | |
| 5523 | if (account.protocol == EntityAccount.TYPE_IMAP && folder.read_only) |
| 5524 | return; |
| 5525 | |
| 5526 | boolean pro = ActivityBilling.isPro(context); |
| 5527 | |
| 5528 | DB db = DB.getInstance(context); |
| 5529 | try { |
| 5530 | boolean executed = false; |
| 5531 | if (pro) { |
| 5532 | int applied = EntityRule.run(context, rules, message, browsed, headers, html); |
| 5533 | executed = (applied > 0); |
| 5534 | } |
| 5535 | |
| 5536 | if (EntityFolder.INBOX.equals(folder.type)) |
| 5537 | if (message.from != null) { |
| 5538 | EntityContact badboy = null; |
| 5539 | for (Address from : message.from) { |
| 5540 | String email = ((InternetAddress) from).getAddress(); |
| 5541 | if (TextUtils.isEmpty(email)) |
| 5542 | continue; |
| 5543 | |
| 5544 | badboy = db.contact().getContact(message.account, EntityContact.TYPE_JUNK, email); |
| 5545 | if (badboy != null) |
| 5546 | break; |
| 5547 | } |
| 5548 | |
| 5549 | if (badboy != null) { |
| 5550 | badboy.times_contacted++; |
| 5551 | badboy.last_contacted = new Date().getTime(); |
| 5552 | db.contact().updateContact(badboy); |
| 5553 | |
| 5554 | EntityFolder junk = db.folder().getFolderByType(message.account, EntityFolder.JUNK); |
| 5555 | if (junk != null) { |
| 5556 | EntityOperation.queue(context, message, EntityOperation.MOVE, junk.id); |
| 5557 | message.ui_hide = true; |
| 5558 | executed = true; |
| 5559 | } |
| 5560 | } |
| 5561 | } |
| 5562 | |
| 5563 | if (executed && |
| 5564 | !message.hasKeyword(MessageHelper.FLAG_FILTERED)) |
| 5565 | EntityOperation.queue(context, message, EntityOperation.KEYWORD, MessageHelper.FLAG_FILTERED, true); |
| 5566 | } catch (Throwable ex) { |
| 5567 | Log.e(ex); |
no test coverage detected