Added message check rule conditions

pull/194/merge
M66B 3 years ago
parent 9275f9027d
commit fb5c810131

@ -2382,13 +2382,13 @@ Some common header conditions (regex):
* *.*Auto-Submitted:.** [RFC3834](https://tools.ietf.org/html/rfc3834)
* *.*Content-Type: multipart/report.** [RFC3462](https://tools.ietf.org/html/rfc3462)
You can match IMAP flags (keywords) via a header condition too (from version 1.1777), like this:
To match *set* IMAP flags (keywords) via a header condition (since version 1.1777):
```
$<keyword>$
```
You can use these special values too, representing common system flags:
To match *set* message flags (since version 1.1777):
```
$$seen$
@ -2397,6 +2397,17 @@ $$flagged$
$$deleted$
```
To match *passed* message checks (since version 1.1787):
```
$$dkim$
$$spf$
$$dmarc$
$$mx$
$$blocklist$
$$replydomain$
```
Note that *regex* should be disable and that there should be no white space.
The automation action will broadcast the intent *eu.faircode.email.AUTOMATION* with the following string extras:

@ -265,21 +265,42 @@ public class EntityRule {
value.endsWith("$")) {
String keyword = value.substring(1, value.length() - 1);
List<String> keywords = new ArrayList<>();
if (message.ui_seen)
keywords.add("$seen");
if (message.ui_answered)
keywords.add("$answered");
if (message.ui_flagged)
keywords.add("$flagged");
if (message.ui_deleted)
keywords.add("$deleted");
if (message.infrastructure != null)
keywords.add('@' + message.infrastructure);
keywords.addAll(Arrays.asList(message.keywords));
if (!keywords.contains(keyword))
return false;
if ("$dkim".equals(keyword)) {
if (!Boolean.TRUE.equals(message.dkim))
return false;
} else if ("$spf".equals(keyword)) {
if (!Boolean.TRUE.equals(message.spf))
return false;
} else if ("$dmarc".equals(keyword)) {
if (!Boolean.TRUE.equals(message.dmarc))
return false;
} else if ("$mx".equals(keyword)) {
if (!Boolean.TRUE.equals(message.mx))
return false;
} else if ("$blocklist".equals(keyword)) {
if (!Boolean.FALSE.equals(message.blocklist))
return false;
} else if ("$replydomain".equals(keyword)) {
if (!Boolean.TRUE.equals(message.reply_domain))
return false;
} else {
List<String> keywords = new ArrayList<>();
keywords.addAll(Arrays.asList(message.keywords));
if (message.ui_seen)
keywords.add("$seen");
if (message.ui_answered)
keywords.add("$answered");
if (message.ui_flagged)
keywords.add("$flagged");
if (message.ui_deleted)
keywords.add("$deleted");
if (message.infrastructure != null)
keywords.add('$' + message.infrastructure);
if (!keywords.contains(keyword))
return false;
}
} else {
if (headers == null) {
if (message.headers == null)

Loading…
Cancel
Save