Refactoring keywords

This commit is contained in:
M66B
2021-07-01 08:00:04 +02:00
parent 2d8f188cf1
commit 302f34ec44
3 changed files with 43 additions and 29 deletions

View File

@@ -121,7 +121,6 @@ public class MessageHelper {
static final int SMALL_MESSAGE_SIZE = 192 * 1024; // bytes
static final int DEFAULT_DOWNLOAD_SIZE = 4 * 1024 * 1024; // bytes
static final String HEADER_CORRELATION_ID = "X-Correlation-ID";
static final String FLAG_FORWARDED = "$Forwarded";
private static final int MAX_HEADER_LENGTH = 998;
private static final int MAX_MESSAGE_SIZE = 10 * 1024 * 1024; // bytes
@@ -135,6 +134,34 @@ public class MessageHelper {
StandardCharsets.UTF_16LE
));
static final String FLAG_FORWARDED = "$Forwarded";
static final String FLAG_NOT_JUNK = "$NotJunk";
// https://www.iana.org/assignments/imap-jmap-keywords/imap-jmap-keywords.xhtml
// Not black listed: Gmail $Phishing
private static final List<String> FLAG_BLACKLIST = Collections.unmodifiableList(Arrays.asList(
MessageHelper.FLAG_FORWARDED,
MessageHelper.FLAG_NOT_JUNK,
"$MDNSent", // https://tools.ietf.org/html/rfc3503
"$SubmitPending",
"$Submitted",
"$Junk",
"Junk",
"NonJunk",
"$recent",
"DTAG_document",
"DTAG_image",
"$X-Me-Annot-1",
"$X-Me-Annot-2",
"\\Unseen", // Mail.ru
"$sent", // Kmail
"$attachment", // Kmail
"$signed", // Kmail
"$encrypted", // Kmail
"$HasNoAttachment",
"$Classified" // FairEmail
));
// https://tools.ietf.org/html/rfc4021
static void setSystemProperties(Context context) {
@@ -915,6 +942,18 @@ public class MessageHelper {
return keywords.toArray(new String[0]);
}
static boolean showKeyword(String keyword) {
if (BuildConfig.DEBUG)
return true;
int len = FLAG_BLACKLIST.size();
for (int i = 0; i < len; i++)
if (FLAG_BLACKLIST.get(i).equalsIgnoreCase(keyword))
return false;
return true;
}
String getMessageID() throws MessagingException {
ensureEnvelope();