mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-30 18:27:45 -05:00
code cleanup
This commit is contained in:
@@ -174,8 +174,8 @@ class MailAccountHandler(LoggingMixin):
|
||||
M.folder.set(rule.folder)
|
||||
except MailboxFolderSelectError:
|
||||
raise MailError(
|
||||
f"Rule {rule.name}: Folder {rule.folder} does not exist "
|
||||
f"in account {account.name}")
|
||||
f"Rule {rule.name}: Folder {rule.folder} "
|
||||
f"does not exist in account {account.name}")
|
||||
|
||||
criterias = make_criterias(rule)
|
||||
|
||||
@@ -185,7 +185,8 @@ class MailAccountHandler(LoggingMixin):
|
||||
f"{str(AND(**criterias))}")
|
||||
|
||||
try:
|
||||
messages = M.fetch(criteria=AND(**criterias), mark_seen=False)
|
||||
messages = M.fetch(criteria=AND(**criterias),
|
||||
mark_seen=False)
|
||||
except Exception:
|
||||
raise MailError(
|
||||
f"Rule {rule.name}: Error while fetching folder "
|
||||
@@ -226,8 +227,8 @@ class MailAccountHandler(LoggingMixin):
|
||||
|
||||
except Exception:
|
||||
raise MailError(
|
||||
f"Rule {rule.name}: Error while processing post-consume "
|
||||
f"actions for account {account.name}")
|
||||
f"Rule {rule.name}: Error while processing "
|
||||
f"post-consume actions for account {account.name}")
|
||||
|
||||
return total_processed_files
|
||||
|
||||
@@ -266,7 +267,8 @@ class MailAccountHandler(LoggingMixin):
|
||||
if is_mime_type_supported(mime_type):
|
||||
|
||||
os.makedirs(settings.SCRATCH_DIR, exist_ok=True)
|
||||
_, temp_filename = tempfile.mkstemp(prefix="paperless-mail-", dir=settings.SCRATCH_DIR)
|
||||
_, temp_filename = tempfile.mkstemp(prefix="paperless-mail-",
|
||||
dir=settings.SCRATCH_DIR)
|
||||
with open(temp_filename, 'wb') as f:
|
||||
f.write(att.payload)
|
||||
|
||||
|
@@ -66,10 +66,14 @@ class MailRule(models.Model):
|
||||
CORRESPONDENT_FROM_CUSTOM = 4
|
||||
|
||||
CORRESPONDENT_SELECTOR = (
|
||||
(CORRESPONDENT_FROM_NOTHING, "Do not assign a correspondent"),
|
||||
(CORRESPONDENT_FROM_EMAIL, "Use mail address"),
|
||||
(CORRESPONDENT_FROM_NAME, "Use name (or mail address if not available)"),
|
||||
(CORRESPONDENT_FROM_CUSTOM, "Use correspondent selected below")
|
||||
(CORRESPONDENT_FROM_NOTHING,
|
||||
"Do not assign a correspondent"),
|
||||
(CORRESPONDENT_FROM_EMAIL,
|
||||
"Use mail address"),
|
||||
(CORRESPONDENT_FROM_NAME,
|
||||
"Use name (or mail address if not available)"),
|
||||
(CORRESPONDENT_FROM_CUSTOM,
|
||||
"Use correspondent selected below")
|
||||
)
|
||||
|
||||
name = models.CharField(max_length=256, unique=True)
|
||||
|
@@ -7,7 +7,8 @@ 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)
|
||||
total_new_documents += MailAccountHandler().handle_mail_account(
|
||||
account)
|
||||
|
||||
if total_new_documents > 0:
|
||||
return f"Added {total_new_documents} document(s)."
|
||||
|
Reference in New Issue
Block a user