mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-08-01 18:37:42 -05:00
fixes #153, adds option for inline attachments and filename filters
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user