mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
25 lines
692 B
Python
25 lines
692 B
Python
import logging
|
|
|
|
from paperless_mail.mail import MailAccountHandler
|
|
from paperless_mail.models import MailAccount
|
|
|
|
|
|
def process_mail_accounts():
|
|
total_new_documents = 0
|
|
for account in MailAccount.objects.all():
|
|
total_new_documents += MailAccountHandler().handle_mail_account(
|
|
account)
|
|
|
|
if total_new_documents > 0:
|
|
return f"Added {total_new_documents} document(s)."
|
|
else:
|
|
return "No new documents were added."
|
|
|
|
|
|
def process_mail_account(name):
|
|
account = MailAccount.objects.find(name=name)
|
|
if account:
|
|
MailAccountHandler().handle_mail_account(account)
|
|
else:
|
|
logging.error("Unknown mail acccount: {}".format(name))
|