1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-01-18 21:28:54 +00:00

Run rules on added messages

This commit is contained in:
M66B 2019-06-13 12:41:50 +02:00
parent 28de9b2b27
commit 35e24c590e

View file

@ -546,17 +546,23 @@ class Core {
Log.i(folder.name + " appended id=" + message.id + " uid=" + uid); Log.i(folder.name + " appended id=" + message.id + " uid=" + uid);
if (folder.id.equals(message.folder)) { try {
Log.i(folder.name + " Setting id=" + message.id + " uid=" + uid); db.beginTransaction();
db.message().setMessageUid(message.id, uid);
} else
try {
db.beginTransaction();
List<EntityRule> rules = db.rule().getEnabledRules(folder.id);
if (folder.id.equals(message.folder)) {
Log.i(folder.name + " Setting id=" + message.id + " uid=" + uid);
db.message().setMessageUid(message.id, uid);
runRules(context, imessage, message, rules);
} else {
// Cross account move // Cross account move
if (tmpid != null) { if (tmpid != null) {
Log.i(folder.name + " Setting id=" + tmpid + " (tmp) appended uid=" + uid); Log.i(folder.name + " Setting id=" + tmpid + " (tmp) appended uid=" + uid);
db.message().setMessageUid(tmpid, uid); db.message().setMessageUid(tmpid, uid);
runRules(context, imessage, db.message().getMessage(tmpid), rules);
} }
// Mark source read // Mark source read
@ -568,11 +574,12 @@ class Core {
// Delete source // Delete source
Log.i(folder.name + " queuing DELETE id=" + message.id); Log.i(folder.name + " queuing DELETE id=" + message.id);
EntityOperation.queue(context, message, EntityOperation.DELETE); EntityOperation.queue(context, message, EntityOperation.DELETE);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
} }
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
} catch (Throwable ex) { } catch (Throwable ex) {
if (folder.id.equals(message.folder)) if (folder.id.equals(message.folder))
db.message().setMessageUid(message.id, message.uid); db.message().setMessageUid(message.id, message.uid);
@ -1540,7 +1547,7 @@ class Core {
} }
} }
private static void runRules(Context context, IMAPMessage imessage, EntityMessage message, List<EntityRule> rules) { private static void runRules(Context context, Message imessage, EntityMessage message, List<EntityRule> rules) {
if (!Helper.isPro(context)) if (!Helper.isPro(context))
return; return;