Merge branch 'dev' into dev
This commit is contained in:
commit
5baa201447
7
.github/workflows/ci.yml
vendored
7
.github/workflows/ci.yml
vendored
@ -22,6 +22,13 @@ env:
|
||||
|
||||
jobs:
|
||||
pre-commit:
|
||||
# We want to run on external PRs, but not on our own internal PRs as they'll be run
|
||||
# by the push to the branch. Without this if check, checks are duplicated since
|
||||
# internal PRs match both the push and pull_request events.
|
||||
if:
|
||||
github.event_name == 'push' || github.event.pull_request.head.repo.full_name !=
|
||||
github.repository
|
||||
|
||||
name: Linting Checks
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
|
@ -254,6 +254,10 @@ a.btn-link:focus-visible,
|
||||
min-height: calc(1.5em + 0.75rem + 5px);
|
||||
line-height: 1.5;
|
||||
|
||||
.ng-select-container {
|
||||
border-radius: $border-radius;
|
||||
}
|
||||
|
||||
.ng-select-container .ng-value-container .ng-input {
|
||||
top: 7px;
|
||||
}
|
||||
@ -311,6 +315,7 @@ textarea,
|
||||
color: var(--bs-body-color);
|
||||
background-color: var(--bs-body-bg);
|
||||
border-color: var(--bs-border-color);
|
||||
font-size: 0.875rem;
|
||||
|
||||
&:focus {
|
||||
background-color: var(--pngx-bg-darker);
|
||||
|
@ -32,7 +32,7 @@ except ImportError: # pragma: nocover
|
||||
logger = logging.getLogger("paperless.management.consumer")
|
||||
|
||||
|
||||
def _tags_from_path(filepath) -> set[Tag]:
|
||||
def _tags_from_path(filepath) -> list[int]:
|
||||
"""
|
||||
Walk up the directory tree from filepath to CONSUMPTION_DIR
|
||||
and get or create Tag IDs for every directory.
|
||||
@ -47,7 +47,7 @@ def _tags_from_path(filepath) -> set[Tag]:
|
||||
Tag.objects.get_or_create(name__iexact=part, defaults={"name": part})[0].pk,
|
||||
)
|
||||
|
||||
return tag_ids
|
||||
return list(tag_ids)
|
||||
|
||||
|
||||
def _is_ignored(filepath: str) -> bool:
|
||||
|
@ -8,6 +8,7 @@ import traceback
|
||||
from datetime import date
|
||||
from datetime import timedelta
|
||||
from fnmatch import fnmatch
|
||||
from typing import Optional
|
||||
from typing import Union
|
||||
|
||||
import magic
|
||||
@ -21,6 +22,7 @@ from django.utils.timezone import is_naive
|
||||
from django.utils.timezone import make_aware
|
||||
from imap_tools import AND
|
||||
from imap_tools import NOT
|
||||
from imap_tools import MailAttachment
|
||||
from imap_tools import MailBox
|
||||
from imap_tools import MailboxFolderSelectError
|
||||
from imap_tools import MailBoxUnencrypted
|
||||
@ -422,14 +424,19 @@ class MailAccountHandler(LoggingMixin):
|
||||
|
||||
logging_name = "paperless_mail"
|
||||
|
||||
def _correspondent_from_name(self, name):
|
||||
def _correspondent_from_name(self, name: str) -> Optional[Correspondent]:
|
||||
try:
|
||||
return Correspondent.objects.get_or_create(name=name)[0]
|
||||
except DatabaseError as e:
|
||||
self.log.error(f"Error while retrieving correspondent {name}: {e}")
|
||||
return None
|
||||
|
||||
def _get_title(self, message, att, rule):
|
||||
def _get_title(
|
||||
self,
|
||||
message: MailMessage,
|
||||
att: MailAttachment,
|
||||
rule: MailRule,
|
||||
) -> Optional[str]:
|
||||
if rule.assign_title_from == MailRule.TitleSource.FROM_SUBJECT:
|
||||
return message.subject
|
||||
|
||||
@ -444,7 +451,11 @@ class MailAccountHandler(LoggingMixin):
|
||||
"Unknown title selector.",
|
||||
) # pragma: nocover
|
||||
|
||||
def _get_correspondent(self, message: MailMessage, rule):
|
||||
def _get_correspondent(
|
||||
self,
|
||||
message: MailMessage,
|
||||
rule: MailRule,
|
||||
) -> Optional[Correspondent]:
|
||||
c_from = rule.assign_correspondent_from
|
||||
|
||||
if c_from == MailRule.CorrespondentSource.FROM_NOTHING:
|
||||
@ -606,7 +617,6 @@ class MailAccountHandler(LoggingMixin):
|
||||
f"{len(message.attachments)} attachment(s)",
|
||||
)
|
||||
|
||||
correspondent = self._get_correspondent(message, rule)
|
||||
tag_ids = [tag.id for tag in rule.assign_tags.all()]
|
||||
doc_type = rule.assign_document_type
|
||||
|
||||
@ -617,7 +627,6 @@ class MailAccountHandler(LoggingMixin):
|
||||
processed_elements += self._process_eml(
|
||||
message,
|
||||
rule,
|
||||
correspondent,
|
||||
tag_ids,
|
||||
doc_type,
|
||||
)
|
||||
@ -629,7 +638,6 @@ class MailAccountHandler(LoggingMixin):
|
||||
processed_elements += self._process_attachments(
|
||||
message,
|
||||
rule,
|
||||
correspondent,
|
||||
tag_ids,
|
||||
doc_type,
|
||||
)
|
||||
@ -640,7 +648,6 @@ class MailAccountHandler(LoggingMixin):
|
||||
self,
|
||||
message: MailMessage,
|
||||
rule: MailRule,
|
||||
correspondent,
|
||||
tag_ids,
|
||||
doc_type,
|
||||
):
|
||||
@ -669,6 +676,8 @@ class MailAccountHandler(LoggingMixin):
|
||||
# as this is system dependent otherwise
|
||||
continue
|
||||
|
||||
correspondent = self._get_correspondent(message, rule)
|
||||
|
||||
title = self._get_title(message, att, rule)
|
||||
|
||||
# don't trust the content type of the attachment. Could be
|
||||
@ -750,7 +759,6 @@ class MailAccountHandler(LoggingMixin):
|
||||
self,
|
||||
message: MailMessage,
|
||||
rule: MailRule,
|
||||
correspondent,
|
||||
tag_ids,
|
||||
doc_type,
|
||||
):
|
||||
@ -781,6 +789,8 @@ class MailAccountHandler(LoggingMixin):
|
||||
|
||||
f.write(message.obj.as_bytes())
|
||||
|
||||
correspondent = self._get_correspondent(message, rule)
|
||||
|
||||
self.log.info(
|
||||
f"Rule {rule}: "
|
||||
f"Consuming eml from mail "
|
||||
|
Loading…
x
Reference in New Issue
Block a user