diff --git a/src/paperless_mail/mail.py b/src/paperless_mail/mail.py index b525ef91d..bfb306e5a 100644 --- a/src/paperless_mail/mail.py +++ b/src/paperless_mail/mail.py @@ -384,6 +384,8 @@ def make_criterias(rule: MailRule, supports_gmail_labels: bool): if isinstance(rule_query, dict): if len(rule_query) or len(criterias): return AND(**rule_query, **criterias) + else: + return "ALL" else: return AND(rule_query, **criterias) diff --git a/src/paperless_mail/tests/test_mail.py b/src/paperless_mail/tests/test_mail.py index e69dbbef8..82b874fd8 100644 --- a/src/paperless_mail/tests/test_mail.py +++ b/src/paperless_mail/tests/test_mail.py @@ -721,6 +721,31 @@ class TestMail( self.assertEqual(len(self.bogus_mailbox.messages), 2) self.assertEqual(len(self.bogus_mailbox.messages_spam), 1) + def test_handle_mail_account_move_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.MOVE, + action_parameter="spam", + maximum_age=0, + ) + + self.assertEqual(len(self.bogus_mailbox.messages), 3) + self.assertEqual(len(self.bogus_mailbox.messages_spam), 0) + + self.mail_account_handler.handle_mail_account(account) + self.apply_mail_actions() + + self.assertEqual(len(self.bogus_mailbox.messages), 0) + self.assertEqual(len(self.bogus_mailbox.messages_spam), 3) + def test_handle_mail_account_tag(self): account = MailAccount.objects.create( name="test",