diff --git a/FAQ.md b/FAQ.md
index e632614985..6028ba36c7 100644
--- a/FAQ.md
+++ b/FAQ.md
@@ -1840,8 +1840,6 @@ it is not possible to preview which messages would match a header rule condition
In the three-dots *more* message menu there is an item to create a rule for a received message with the most common conditions filled in.
-Rules are available for IMAP accounts only because the POP3 protocol allows downloading and permanently deleting messages from the inbox only.
-
Using rules is a pro feature.
diff --git a/app/src/main/java/eu/faircode/email/AdapterFolder.java b/app/src/main/java/eu/faircode/email/AdapterFolder.java
index 5077e8a525..55d3e20acb 100644
--- a/app/src/main/java/eu/faircode/email/AdapterFolder.java
+++ b/app/src/main/java/eu/faircode/email/AdapterFolder.java
@@ -520,6 +520,9 @@ public class AdapterFolder extends RecyclerView.Adapter 0)
rule.putExtra("sender", ((InternetAddress) message.from[0]).getAddress());
if (message.to != null && message.to.length > 0)
diff --git a/app/src/main/java/eu/faircode/email/AdapterRule.java b/app/src/main/java/eu/faircode/email/AdapterRule.java
index 8639d87412..311669a397 100644
--- a/app/src/main/java/eu/faircode/email/AdapterRule.java
+++ b/app/src/main/java/eu/faircode/email/AdapterRule.java
@@ -66,6 +66,7 @@ public class AdapterRule extends RecyclerView.Adapter {
private LifecycleOwner owner;
private LayoutInflater inflater;
+ private int protocol = -1;
private List items = new ArrayList<>();
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
@@ -192,7 +193,8 @@ public class AdapterRule extends RecyclerView.Adapter {
new Intent(ActivityView.ACTION_EDIT_RULE)
.putExtra("id", rule.id)
.putExtra("account", rule.account)
- .putExtra("folder", rule.folder));
+ .putExtra("folder", rule.folder)
+ .putExtra("protocol", protocol));
}
@Override
@@ -215,8 +217,10 @@ public class AdapterRule extends RecyclerView.Adapter {
popupMenu.getMenu().add(Menu.NONE, R.string.title_rule_execute, 2, R.string.title_rule_execute)
.setEnabled(ActivityBilling.isPro(context));
popupMenu.getMenu().add(Menu.NONE, R.string.title_reset, 3, R.string.title_reset);
- popupMenu.getMenu().add(Menu.NONE, R.string.title_move_to_folder, 4, R.string.title_move_to_folder);
- popupMenu.getMenu().add(Menu.NONE, R.string.title_copy, 5, R.string.title_copy);
+ if (protocol == EntityAccount.TYPE_IMAP) {
+ popupMenu.getMenu().add(Menu.NONE, R.string.title_move_to_folder, 4, R.string.title_move_to_folder);
+ popupMenu.getMenu().add(Menu.NONE, R.string.title_copy, 5, R.string.title_copy);
+ }
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
@@ -378,6 +382,7 @@ public class AdapterRule extends RecyclerView.Adapter {
.putExtra("id", rule.id)
.putExtra("account", rule.account)
.putExtra("folder", rule.folder)
+ .putExtra("protocol", protocol)
.putExtra("copy", true));
}
});
@@ -405,8 +410,9 @@ public class AdapterRule extends RecyclerView.Adapter {
});
}
- public void set(@NonNull List rules) {
- Log.i("Set rules=" + rules.size());
+ public void set(int protocol, @NonNull List rules) {
+ this.protocol = protocol;
+ Log.i("Set protocol=" + protocol + " rules=" + rules.size());
DiffUtil.DiffResult diff = DiffUtil.calculateDiff(new DiffCallback(items, rules), false);
diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java
index eb3068aee1..51a49779e4 100644
--- a/app/src/main/java/eu/faircode/email/Core.java
+++ b/app/src/main/java/eu/faircode/email/Core.java
@@ -1689,6 +1689,8 @@ class Core {
return;
}
+ List rules = db.rule().getEnabledRules(folder.id);
+
try {
db.folder().setFolderSyncState(folder.id, "syncing");
@@ -1843,8 +1845,7 @@ class Core {
attachment.id = db.attachment().insertAttachment(attachment);
}
- // No rules
-
+ runRules(context, imessage, account, folder, message, rules);
reportNewMessage(context, account, folder, message);
db.setTransactionSuccessful();
diff --git a/app/src/main/java/eu/faircode/email/FragmentRule.java b/app/src/main/java/eu/faircode/email/FragmentRule.java
index b25b7da7a3..b5213f9c33 100644
--- a/app/src/main/java/eu/faircode/email/FragmentRule.java
+++ b/app/src/main/java/eu/faircode/email/FragmentRule.java
@@ -158,6 +158,7 @@ public class FragmentRule extends FragmentBase {
private long copy = -1;
private long account = -1;
private long folder = -1;
+ private int protocol = -1;
private final static int MAX_CHECK = 10;
@@ -180,6 +181,7 @@ public class FragmentRule extends FragmentBase {
id = args.getLong("id", -1);
account = args.getLong("account", -1);
folder = args.getLong("folder", -1);
+ protocol = args.getInt("protocol", EntityAccount.TYPE_IMAP);
}
@Override
@@ -383,9 +385,11 @@ public class FragmentRule extends FragmentBase {
actions.add(new Action(EntityRule.TYPE_SNOOZE, getString(R.string.title_rule_snooze)));
actions.add(new Action(EntityRule.TYPE_FLAG, getString(R.string.title_rule_flag)));
actions.add(new Action(EntityRule.TYPE_IMPORTANCE, getString(R.string.title_rule_importance)));
- actions.add(new Action(EntityRule.TYPE_KEYWORD, getString(R.string.title_rule_keyword)));
- actions.add(new Action(EntityRule.TYPE_MOVE, getString(R.string.title_rule_move)));
- actions.add(new Action(EntityRule.TYPE_COPY, getString(R.string.title_rule_copy)));
+ if (protocol == EntityAccount.TYPE_IMAP) {
+ actions.add(new Action(EntityRule.TYPE_KEYWORD, getString(R.string.title_rule_keyword)));
+ actions.add(new Action(EntityRule.TYPE_MOVE, getString(R.string.title_rule_move)));
+ actions.add(new Action(EntityRule.TYPE_COPY, getString(R.string.title_rule_copy)));
+ }
actions.add(new Action(EntityRule.TYPE_ANSWER, getString(R.string.title_rule_answer)));
actions.add(new Action(EntityRule.TYPE_AUTOMATION, getString(R.string.title_rule_automation)));
adapterAction.addAll(actions);
diff --git a/app/src/main/java/eu/faircode/email/FragmentRules.java b/app/src/main/java/eu/faircode/email/FragmentRules.java
index 9095aceb95..0cae69593b 100644
--- a/app/src/main/java/eu/faircode/email/FragmentRules.java
+++ b/app/src/main/java/eu/faircode/email/FragmentRules.java
@@ -48,6 +48,7 @@ import static android.app.Activity.RESULT_OK;
public class FragmentRules extends FragmentBase {
private long account;
private long folder;
+ private int protocol;
private boolean cards;
@@ -68,6 +69,7 @@ public class FragmentRules extends FragmentBase {
Bundle args = getArguments();
account = args.getLong("account", -1);
folder = args.getLong("folder", -1);
+ protocol = args.getInt("protocol", -1);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
cards = prefs.getBoolean("cards", true);
@@ -107,6 +109,7 @@ public class FragmentRules extends FragmentBase {
Bundle args = new Bundle();
args.putLong("account", account);
args.putLong("folder", folder);
+ args.putInt("protocol", protocol);
FragmentRule fragment = new FragmentRule();
fragment.setArguments(args);
@@ -139,7 +142,7 @@ public class FragmentRules extends FragmentBase {
if (rules == null)
rules = new ArrayList<>();
- adapter.set(rules);
+ adapter.set(protocol, rules);
pbWait.setVisibility(View.GONE);
grpReady.setVisibility(View.VISIBLE);