|
|
@ -68,33 +68,36 @@ public class WorkerDailyRules extends Worker {
|
|
|
|
|
|
|
|
|
|
|
|
int count = 0;
|
|
|
|
int count = 0;
|
|
|
|
List<Long> mids = db.message().getMessageIdsByFolder(folder.id);
|
|
|
|
List<Long> mids = db.message().getMessageIdsByFolder(folder.id);
|
|
|
|
for (long mid : mids) {
|
|
|
|
for (long mid : mids)
|
|
|
|
EntityMessage message = db.message().getMessage(mid);
|
|
|
|
try {
|
|
|
|
if (message == null)
|
|
|
|
EntityMessage message = db.message().getMessage(mid);
|
|
|
|
continue;
|
|
|
|
if (message == null)
|
|
|
|
count++;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
count++;
|
|
|
|
boolean needsHeaders = EntityRule.needsHeaders(message, rules);
|
|
|
|
|
|
|
|
boolean needsBody = EntityRule.needsBody(message, rules);
|
|
|
|
boolean needsHeaders = EntityRule.needsHeaders(message, rules);
|
|
|
|
|
|
|
|
boolean needsBody = EntityRule.needsBody(message, rules);
|
|
|
|
if (needsHeaders && message.headers == null) {
|
|
|
|
|
|
|
|
EntityOperation.queue(context, message, EntityOperation.HEADERS);
|
|
|
|
if (needsHeaders && message.headers == null) {
|
|
|
|
continue;
|
|
|
|
EntityOperation.queue(context, message, EntityOperation.HEADERS);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
if (needsBody && !message.content) {
|
|
|
|
|
|
|
|
EntityOperation.queue(context, message, EntityOperation.BODY);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (EntityRule rule : rules)
|
|
|
|
if (needsBody && !message.content) {
|
|
|
|
if (rule.daily &&
|
|
|
|
EntityOperation.queue(context, message, EntityOperation.BODY);
|
|
|
|
rule.matches(context, message, null, null)) {
|
|
|
|
continue;
|
|
|
|
rule.execute(context, message);
|
|
|
|
|
|
|
|
if (rule.stop)
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (EntityRule rule : rules)
|
|
|
|
|
|
|
|
if (rule.daily &&
|
|
|
|
|
|
|
|
rule.matches(context, message, null, null)) {
|
|
|
|
|
|
|
|
rule.execute(context, message);
|
|
|
|
|
|
|
|
if (rule.stop)
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
|
|
|
|
Log.e(ex);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EntityLog.log(context, EntityLog.Type.Rules, folder,
|
|
|
|
EntityLog.log(context, EntityLog.Type.Rules, folder,
|
|
|
|
"Executed " + count + " rules for " + account.name + "/" + folder.name);
|
|
|
|
"Executed " + count + " rules for " + account.name + "/" + folder.name);
|
|
|
|