Return default 'ALL' mailbox criterias for some imap servers

This commit is contained in:
shamoon 2023-06-06 20:00:31 -07:00
parent 36b4fff5c7
commit 0ebe08d796
2 changed files with 27 additions and 0 deletions

View File

@ -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)

View File

@ -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",