diff --git a/src/documents/tests/test_migration_workflows.py b/src/documents/tests/test_migration_workflows.py index 81bb577b2..34e2afb5b 100644 --- a/src/documents/tests/test_migration_workflows.py +++ b/src/documents/tests/test_migration_workflows.py @@ -8,7 +8,7 @@ class TestMigrateWorkflow(TestMigrations): dependencies = ( ( "paperless_mail", - "0026_mailrule_enabled", + "0027_mailaccount_expiration_mailaccount_refresh_token", ), ) diff --git a/src/paperless_mail/mail.py b/src/paperless_mail/mail.py index b86414674..16f7e3634 100644 --- a/src/paperless_mail/mail.py +++ b/src/paperless_mail/mail.py @@ -572,7 +572,11 @@ class MailAccountHandler(LoggingMixin): account.imap_port, account.imap_security, ) as M: - if account.is_token and account.expiration < timezone.now(): + if ( + account.is_token + and account.expiration is not None + and account.expiration < timezone.now() + ): self.log.debug(f"Attempting to refresh token for account {account}") success = self.refresh_token(account) if not success: