Added keywords to header condition

pull/194/merge
M66B 3 years ago
parent 8a8e27b757
commit e4d754b5cc

@ -2363,6 +2363,23 @@ 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:
```
$<keyword>$
```
You can use these special values too, representing common system flags:
```
$$seen$
$$answered$
$$flagged$
$$deleted$
```
Note that *regex* should be disable and that there should be no white space.
In the three-dots *more* message menu there is an item to create a rule for a received message with the most common conditions filled in.
The POP3 protocol does not support setting keywords and moving or copying messages.

@ -239,6 +239,26 @@ public class EntityRule {
String value = jheader.getString("value");
boolean regex = jheader.getBoolean("regex");
if (!regex &&
value != null &&
value.startsWith("$") &&
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");
keywords.addAll(Arrays.asList(message.keywords));
if (!keywords.contains(keyword))
return false;
} else {
boolean matches = false;
Enumeration<Header> headers;
if (imessage != null)
@ -259,6 +279,7 @@ public class EntityRule {
if (!matches)
return false;
}
}
// Date
JSONObject jdate = jcondition.optJSONObject("date");

Loading…
Cancel
Save