|
|
@ -1774,7 +1774,7 @@ class Core {
|
|
|
|
|
|
|
|
|
|
|
|
SyncStats stats = new SyncStats();
|
|
|
|
SyncStats stats = new SyncStats();
|
|
|
|
boolean download = db.folder().getFolderDownload(folder.id);
|
|
|
|
boolean download = db.folder().getFolderDownload(folder.id);
|
|
|
|
List<EntityRule> rules = db.rule().getEnabledRules(folder.id);
|
|
|
|
List<EntityRule> rules = db.rule().getEnabledRules(folder.id, false);
|
|
|
|
|
|
|
|
|
|
|
|
FetchProfile fp = new FetchProfile();
|
|
|
|
FetchProfile fp = new FetchProfile();
|
|
|
|
fp.add(UIDFolder.FetchProfileItem.UID); // To check if message exists
|
|
|
|
fp.add(UIDFolder.FetchProfileItem.UID); // To check if message exists
|
|
|
@ -2996,18 +2996,28 @@ class Core {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static void onRule(Context context, JSONArray jargs, EntityMessage message) throws JSONException, MessagingException {
|
|
|
|
private static void onRule(Context context, JSONArray jargs, EntityMessage message) throws JSONException, MessagingException {
|
|
|
|
// Download message body
|
|
|
|
// Deferred rule (download headers, body, etc)
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
|
|
|
|
|
|
|
long id = jargs.getLong(0);
|
|
|
|
long id = jargs.getLong(0);
|
|
|
|
EntityRule rule = db.rule().getRule(id);
|
|
|
|
if (id < 0) {
|
|
|
|
if (rule == null)
|
|
|
|
List<EntityRule> rules = db.rule().getEnabledRules(message.folder, true);
|
|
|
|
throw new IllegalArgumentException("Rule not found id=" + id);
|
|
|
|
for (EntityRule rule : rules)
|
|
|
|
|
|
|
|
if (rule.matches(context, message, null, null)) {
|
|
|
|
|
|
|
|
rule.execute(context, message);
|
|
|
|
|
|
|
|
if (rule.stop)
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
EntityRule rule = db.rule().getRule(id);
|
|
|
|
|
|
|
|
if (rule == null)
|
|
|
|
|
|
|
|
throw new IllegalArgumentException("Rule not found id=" + id);
|
|
|
|
|
|
|
|
|
|
|
|
if (!message.content)
|
|
|
|
if (!message.content)
|
|
|
|
throw new IllegalArgumentException("Message without content id=" + rule.id + ":" + rule.name);
|
|
|
|
throw new IllegalArgumentException("Message without content id=" + rule.id + ":" + rule.name);
|
|
|
|
|
|
|
|
|
|
|
|
rule.execute(context, message);
|
|
|
|
rule.execute(context, message);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static void onDownload(Context context, JSONArray jargs, EntityAccount account, EntityFolder folder, EntityMessage message, IMAPStore istore, IMAPFolder ifolder, State state) throws MessagingException, IOException, JSONException {
|
|
|
|
private static void onDownload(Context context, JSONArray jargs, EntityAccount account, EntityFolder folder, EntityMessage message, IMAPStore istore, IMAPFolder ifolder, State state) throws MessagingException, IOException, JSONException {
|
|
|
@ -3046,7 +3056,7 @@ class Core {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<EntityRule> rules = db.rule().getEnabledRules(folder.id);
|
|
|
|
List<EntityRule> rules = db.rule().getEnabledRules(folder.id, false);
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
db.folder().setFolderSyncState(folder.id, "syncing");
|
|
|
|
db.folder().setFolderSyncState(folder.id, "syncing");
|
|
|
@ -3939,7 +3949,7 @@ class Core {
|
|
|
|
Log.i(folder.name + " delete local uid=" + uid + " count=" + count);
|
|
|
|
Log.i(folder.name + " delete local uid=" + uid + " count=" + count);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<EntityRule> rules = db.rule().getEnabledRules(folder.id);
|
|
|
|
List<EntityRule> rules = db.rule().getEnabledRules(folder.id, false);
|
|
|
|
|
|
|
|
|
|
|
|
fp.add(FetchProfile.Item.ENVELOPE);
|
|
|
|
fp.add(FetchProfile.Item.ENVELOPE);
|
|
|
|
//fp.add(FetchProfile.Item.FLAGS);
|
|
|
|
//fp.add(FetchProfile.Item.FLAGS);
|
|
|
@ -5004,8 +5014,7 @@ class Core {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
boolean executed = false;
|
|
|
|
boolean executed = false;
|
|
|
|
for (EntityRule rule : rules)
|
|
|
|
for (EntityRule rule : rules)
|
|
|
|
if (!rule.daily &&
|
|
|
|
if (rule.matches(context, message, headers, html)) {
|
|
|
|
rule.matches(context, message, headers, html)) {
|
|
|
|
|
|
|
|
rule.execute(context, message);
|
|
|
|
rule.execute(context, message);
|
|
|
|
executed = true;
|
|
|
|
executed = true;
|
|
|
|
if (rule.stop)
|
|
|
|
if (rule.stop)
|
|
|
|