mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Merge pull request #3161 from paperless-ngx/fix/issue-3160
Fix: Handle delete mail action with no filters
This commit is contained in:
commit
08ac40dd48
@ -381,7 +381,8 @@ def make_criterias(rule):
|
||||
|
||||
rule_query = get_rule_action(rule).get_criteria()
|
||||
if isinstance(rule_query, dict):
|
||||
return AND(**rule_query, **criterias)
|
||||
if len(rule_query) or len(criterias):
|
||||
return AND(**rule_query, **criterias)
|
||||
else:
|
||||
return AND(rule_query, **criterias)
|
||||
|
||||
|
@ -612,6 +612,29 @@ class TestMail(
|
||||
|
||||
self.assertEqual(len(self.bogus_mailbox.messages), 1)
|
||||
|
||||
def test_handle_mail_account_delete_no_filters(self):
|
||||
|
||||
account = MailAccount.objects.create(
|
||||
name="test",
|
||||
imap_server="",
|
||||
username="admin",
|
||||
password="secret",
|
||||
)
|
||||
|
||||
_ = MailRule.objects.create(
|
||||
name="testrule",
|
||||
account=account,
|
||||
action=MailRule.MailAction.DELETE,
|
||||
maximum_age=0,
|
||||
)
|
||||
|
||||
self.assertEqual(len(self.bogus_mailbox.messages), 3)
|
||||
|
||||
self.mail_account_handler.handle_mail_account(account)
|
||||
self.apply_mail_actions()
|
||||
|
||||
self.assertEqual(len(self.bogus_mailbox.messages), 0)
|
||||
|
||||
def test_handle_mail_account_flag(self):
|
||||
account = MailAccount.objects.create(
|
||||
name="test",
|
||||
|
Loading…
x
Reference in New Issue
Block a user