|
|
@ -70,13 +70,20 @@ public class WorkerDailyRules extends Worker {
|
|
|
|
for (EntityAccount account : accounts) {
|
|
|
|
for (EntityAccount account : accounts) {
|
|
|
|
List<EntityFolder> folders = db.folder().getFolders(account.id, false, false);
|
|
|
|
List<EntityFolder> folders = db.folder().getFolders(account.id, false, false);
|
|
|
|
for (EntityFolder folder : folders) {
|
|
|
|
for (EntityFolder folder : folders) {
|
|
|
|
|
|
|
|
EntityLog.log(context, "Executing daily rules for " + account.name + "/" + folder.name);
|
|
|
|
|
|
|
|
|
|
|
|
List<EntityRule> rules = db.rule().getEnabledRules(folder.id, true);
|
|
|
|
List<EntityRule> rules = db.rule().getEnabledRules(folder.id, true);
|
|
|
|
if (rules.size() == 0)
|
|
|
|
if (rules == null || rules.size() == 0)
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
EntityLog.log(context, "Executing daily rules count=" + rules.size());
|
|
|
|
|
|
|
|
|
|
|
|
int count = 0;
|
|
|
|
int count = 0;
|
|
|
|
List<Long> mids = db.message().getMessageIdsByFolder(folder.id);
|
|
|
|
List<Long> ids = db.message().getMessageIdsByFolder(folder.id);
|
|
|
|
for (long mid : mids)
|
|
|
|
if (ids == null || ids.size() == 0)
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
EntityLog.log(context, "Executing daily rules messages=" + ids.size());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (long mid : ids)
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
db.beginTransaction();
|
|
|
|
db.beginTransaction();
|
|
|
|
|
|
|
|
|
|
|
@ -91,11 +98,13 @@ public class WorkerDailyRules extends Worker {
|
|
|
|
|
|
|
|
|
|
|
|
if (needsHeaders && message.headers == null) {
|
|
|
|
if (needsHeaders && message.headers == null) {
|
|
|
|
defer = true;
|
|
|
|
defer = true;
|
|
|
|
|
|
|
|
EntityLog.log(context, "Deferring daily rules for headers message=" + message.id);
|
|
|
|
EntityOperation.queue(context, message, EntityOperation.HEADERS);
|
|
|
|
EntityOperation.queue(context, message, EntityOperation.HEADERS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (needsBody && !message.content) {
|
|
|
|
if (needsBody && !message.content) {
|
|
|
|
defer = true;
|
|
|
|
defer = true;
|
|
|
|
|
|
|
|
EntityLog.log(context, "Deferring daily rules for body message=" + message.id);
|
|
|
|
EntityOperation.queue(context, message, EntityOperation.BODY);
|
|
|
|
EntityOperation.queue(context, message, EntityOperation.BODY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -104,6 +113,7 @@ public class WorkerDailyRules extends Worker {
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EntityLog.log(context, "Executing daily rules message=" + message.id);
|
|
|
|
EntityRule.run(context, rules, message, null, null);
|
|
|
|
EntityRule.run(context, rules, message, null, null);
|
|
|
|
|
|
|
|
|
|
|
|
db.setTransactionSuccessful();
|
|
|
|
db.setTransactionSuccessful();
|
|
|
|