fixes #153, adds option for inline attachments and filename filters

This commit is contained in:
jonaswinkler
2021-01-06 02:39:59 +01:00
parent 6e84668884
commit e107d5df6f
5 changed files with 101 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
import os
import tempfile
from datetime import timedelta, date
from fnmatch import fnmatch
import magic
import pathvalidate
@@ -263,7 +264,7 @@ class MailAccountHandler(LoggingMixin):
for att in message.attachments:
if not att.content_disposition == "attachment":
if not att.content_disposition == "attachment" and rule.attachment_type == MailRule.ATTACHMENT_TYPE_ATTACHMENTS_ONLY: # NOQA: E501
self.log(
'debug',
f"Rule {rule}: "
@@ -271,6 +272,10 @@ class MailAccountHandler(LoggingMixin):
f"with content disposition {att.content_disposition}")
continue
if rule.filter_attachment_filename:
if not fnmatch(att.filename, rule.filter_attachment_filename):
continue
title = self.get_title(message, att, rule)
# don't trust the content type of the attachment. Could be