(Context context, JSONArray jargs, EntityMessage message)
| 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); |
no test coverage detected