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

Method needs

app/src/main/java/eu/faircode/email/EntityRule.java:182–217  ·  view source on GitHub ↗
(List<EntityRule> rules, String what)

Source from the content-addressed store, hash-verified

180 }
181
182 private static boolean needs(List<EntityRule> rules, String what) {
183 for (EntityRule rule : rules)
184 try {
185 JSONObject jaction = new JSONObject(rule.action);
186 int type = jaction.getInt("type");
187 if (type == TYPE_SUMMARIZE || type == TYPE_AUTOMATION)
188 return true;
189
190 JSONObject jcondition = new JSONObject(rule.condition);
191
192 if (jcondition.has(what)) {
193 if ("header".equals(what)) {
194 JSONObject jheader = jcondition.getJSONObject("header");
195 String value = jheader.getString("value");
196 boolean regex = jheader.getBoolean("regex");
197 if (!regex && value.startsWith("$$") && value.endsWith("$"))
198 continue;
199 }
200 return true;
201 }
202
203 if (jcondition.has("expression")) {
204 Expression expression = ExpressionHelper.getExpression(rule, null, null, null, null);
205 if (expression != null) {
206 if ("header".equals(what) && ExpressionHelper.needsHeaders(expression))
207 return true;
208 if ("body".equals(what) && ExpressionHelper.needsBody(expression))
209 return true;
210 }
211 }
212 } catch (Throwable ex) {
213 Log.e(ex);
214 }
215
216 return false;
217 }
218
219 static int run(Context context, List<EntityRule> rules,
220 EntityMessage message, boolean browsed, List<Header> headers, String html)

Callers 2

needsHeadersMethod · 0.95
needsBodyMethod · 0.95

Calls 8

getExpressionMethod · 0.95
needsHeadersMethod · 0.95
needsBodyMethod · 0.95
eMethod · 0.95
getBooleanMethod · 0.80
getIntMethod · 0.45
equalsMethod · 0.45
getStringMethod · 0.45

Tested by

no test coverage detected