1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-02-23 14:41:08 +00:00

Added keywords to header condition

This commit is contained in:
M66B 2021-11-10 16:01:19 +01:00
parent 8a8e27b757
commit e4d754b5cc
2 changed files with 55 additions and 17 deletions

17
FAQ.md
View file

@ -2363,6 +2363,23 @@ Some common header conditions (regex):
* *.*Auto-Submitted:.** [RFC3834](https://tools.ietf.org/html/rfc3834) * *.*Auto-Submitted:.** [RFC3834](https://tools.ietf.org/html/rfc3834)
* *.*Content-Type: multipart/report.** [RFC3462](https://tools.ietf.org/html/rfc3462) * *.*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. 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. The POP3 protocol does not support setting keywords and moving or copying messages.

View file

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