MCPcopy Create free account
hub / github.com/M66B/FairEmail / onRule

Method onRule

app/src/main/java/eu/faircode/email/Core.java:3275–3304  ·  view source on GitHub ↗
(Context context, JSONArray jargs, EntityMessage message)

Source from the content-addressed store, hash-verified

3273 }
3274
3275 private static void onRule(Context context, JSONArray jargs, EntityMessage message) throws JSONException, MessagingException, IOException {
3276 // Deferred rule (download headers, body, etc)
3277 DB db = DB.getInstance(context);
3278
3279 try {
3280 db.beginTransaction();
3281
3282 long id = jargs.getLong(0);
3283 boolean browsed = jargs.optBoolean(1);
3284 if (id < 0) {
3285 EntityLog.log(context, "Executing deferred daily rules for message=" + message.id);
3286 List<EntityRule> rules = db.rule().getEnabledRules(message.folder, true);
3287 EntityRule.run(context, rules, message, browsed, null, null);
3288 } else {
3289 EntityRule rule = db.rule().getRule(id);
3290 if (rule == null)
3291 throw new IllegalArgumentException("Rule not found id=" + id);
3292
3293 if (!message.content)
3294 throw new IllegalArgumentException("Message without content id=" + rule.id + ":" + rule.name);
3295
3296 rule.async = true;
3297 rule.execute(context, message, browsed, null);
3298 }
3299
3300 db.setTransactionSuccessful();
3301 } finally {
3302 db.endTransaction();
3303 }
3304 }
3305
3306 private static void onDownload(Context context, JSONArray jargs, EntityAccount account, EntityFolder folder, EntityMessage message, IMAPStore istore, IMAPFolder ifolder, State state) throws MessagingException, IOException, JSONException {
3307 long uid = jargs.getLong(0);

Callers 1

processOperationsMethod · 0.95

Calls 11

getInstanceMethod · 0.95
beginTransactionMethod · 0.95
logMethod · 0.95
ruleMethod · 0.95
runMethod · 0.95
executeMethod · 0.95
endTransactionMethod · 0.95
getLongMethod · 0.80
getEnabledRulesMethod · 0.80
getRuleMethod · 0.80

Tested by

no test coverage detected