mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-15 11:07:00 +01:00
Enhancement: re-work mail rule dialog, support multiple include patterns (#7635)
This commit is contained in:
parent
e1ba1a1898
commit
4903e4290d
5 changed files with 143 additions and 100 deletions
|
|
@ -686,6 +686,25 @@ class MailAccountHandler(LoggingMixin):
|
|||
|
||||
return processed_elements
|
||||
|
||||
def filename_inclusion_matches(
|
||||
self,
|
||||
filter_attachment_filename_include: Optional[str],
|
||||
filename: str,
|
||||
) -> bool:
|
||||
if filter_attachment_filename_include:
|
||||
filter_attachment_filename_inclusions = (
|
||||
filter_attachment_filename_include.split(",")
|
||||
)
|
||||
|
||||
# Force the filename and pattern to the lowercase
|
||||
# as this is system dependent otherwise
|
||||
filename = filename.lower()
|
||||
for filename_include in filter_attachment_filename_inclusions:
|
||||
if filename_include and fnmatch(filename, filename_include.lower()):
|
||||
return True
|
||||
return False
|
||||
return True
|
||||
|
||||
def filename_exclusion_matches(
|
||||
self,
|
||||
filter_attachment_filename_exclude: Optional[str],
|
||||
|
|
@ -728,9 +747,9 @@ class MailAccountHandler(LoggingMixin):
|
|||
)
|
||||
continue
|
||||
|
||||
if rule.filter_attachment_filename_include and not fnmatch(
|
||||
att.filename.lower(),
|
||||
rule.filter_attachment_filename_include.lower(),
|
||||
if not self.filename_inclusion_matches(
|
||||
rule.filter_attachment_filename_include,
|
||||
att.filename,
|
||||
):
|
||||
# Force the filename and pattern to the lowercase
|
||||
# as this is system dependent otherwise
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue