From 726ea077ff1c0385d15587a116d3c2c46f7cc987 Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 17 Apr 2024 19:23:33 +0200 Subject: [PATCH] Refactoring --- .../main/java/eu/faircode/email/EntityRule.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/EntityRule.java b/app/src/main/java/eu/faircode/email/EntityRule.java index 919b80636e..eed7bdde84 100644 --- a/app/src/main/java/eu/faircode/email/EntityRule.java +++ b/app/src/main/java/eu/faircode/email/EntityRule.java @@ -208,10 +208,8 @@ public class EntityRule { if (expression != null) { if ("header".equals(what) && needsHeaders(expression)) return true; - if ("body".equals(what)) - for (String variable : expression.getUsedVariables()) - if ("text".equalsIgnoreCase(variable)) - return true; + if ("body".equals(what) && needsBody(expression)) + return true; } } } catch (Throwable ex) { @@ -759,6 +757,17 @@ public class EntityRule { return false; } + static boolean needsBody(Expression expression) { + try { + for (String variable : expression.getUsedVariables()) + if ("text".equalsIgnoreCase(variable)) + return true; + } catch (Throwable ex) { + Log.e(ex); + } + return false; + } + boolean execute(Context context, EntityMessage message, String html) throws JSONException, IOException { boolean executed = _execute(context, message, html); if (this.id != null && executed) {