mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-10-12 02:26:09 -05:00
Enhancement: Allow excluding mail attachments by name (#4691)
* Adds new filtering to exclude attachments from processing * Frontend use include / exclude mail rule filename filters --------- Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
@@ -668,12 +668,29 @@ class MailAccountHandler(LoggingMixin):
|
||||
)
|
||||
continue
|
||||
|
||||
if rule.filter_attachment_filename and not fnmatch(
|
||||
if rule.filter_attachment_filename_include and not fnmatch(
|
||||
att.filename.lower(),
|
||||
rule.filter_attachment_filename.lower(),
|
||||
rule.filter_attachment_filename_include.lower(),
|
||||
):
|
||||
# Force the filename and pattern to the lowercase
|
||||
# as this is system dependent otherwise
|
||||
self.log.debug(
|
||||
f"Rule {rule}: "
|
||||
f"Skipping attachment {att.filename} "
|
||||
f"does not match pattern {rule.filter_attachment_filename_include}",
|
||||
)
|
||||
continue
|
||||
elif rule.filter_attachment_filename_exclude and fnmatch(
|
||||
att.filename.lower(),
|
||||
rule.filter_attachment_filename_exclude.lower(),
|
||||
):
|
||||
# Force the filename and pattern to the lowercase
|
||||
# as this is system dependent otherwise
|
||||
self.log.debug(
|
||||
f"Rule {rule}: "
|
||||
f"Skipping attachment {att.filename} "
|
||||
f"does match pattern {rule.filter_attachment_filename_exclude}",
|
||||
)
|
||||
continue
|
||||
|
||||
correspondent = self._get_correspondent(message, rule)
|
||||
|
Reference in New Issue
Block a user