Allow rules for specific attachment mime types

This commit is contained in:
M66B
2020-06-20 09:35:05 +02:00
parent 3754cf966c
commit 6afefb61b7
4 changed files with 52 additions and 2 deletions

View File

@@ -194,8 +194,23 @@ public class EntityRule {
// Attachments
if (jcondition.optBoolean("attachments")) {
DB db = DB.getInstance(context);
if (db.attachment().getAttachments(message.id).size() == 0)
List<EntityAttachment> attachments = db.attachment().getAttachments(message.id);
if (attachments.size() == 0)
return false;
if (jcondition.has("mimetype")) {
String mimeType = jcondition.getString("mimetype");
boolean found = false;
for (EntityAttachment attachment : attachments)
if (mimeType.equalsIgnoreCase(attachment.type)) {
found = true;
break;
}
if (!found)
return false;
}
}
// Header