From cb271deb8f2810504ce43676634f75c96a585a48 Mon Sep 17 00:00:00 2001 From: Trenton H <797416+stumpylog@users.noreply.github.com> Date: Wed, 25 Oct 2023 16:18:13 -0700 Subject: [PATCH 1/4] Fixes the returning of a set, change to a list instead (#4442) --- src/documents/management/commands/document_consumer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/documents/management/commands/document_consumer.py b/src/documents/management/commands/document_consumer.py index 64812ed88..f9f50dcb4 100644 --- a/src/documents/management/commands/document_consumer.py +++ b/src/documents/management/commands/document_consumer.py @@ -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: From dcc2cc5001b7727bda646161fa67b6502051defa Mon Sep 17 00:00:00 2001 From: Trenton H <797416+stumpylog@users.noreply.github.com> Date: Wed, 25 Oct 2023 17:34:52 -0700 Subject: [PATCH 2/4] Only get or create a Correspondent if the email or attachment matches rule filters (#4431) --- src/paperless_mail/mail.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/paperless_mail/mail.py b/src/paperless_mail/mail.py index 0157ea773..f3ebc35df 100644 --- a/src/paperless_mail/mail.py +++ b/src/paperless_mail/mail.py @@ -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 " From 4fbe7f16f3f31bcc16d507be930fd6d6f487b9d6 Mon Sep 17 00:00:00 2001 From: Trenton H <797416+stumpylog@users.noreply.github.com> Date: Wed, 25 Oct 2023 18:05:52 -0700 Subject: [PATCH 3/4] Stops duplicated action runs against internal PRs (#4430) --- .github/workflows/ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7c22e9f98..249da50a7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: From f695d4b9daa2a4a4ddc78a09e2a2e52d8529b760 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Fri, 27 Oct 2023 11:41:55 -0700 Subject: [PATCH 4/4] Fix: correct some form typography and styling --- src-ui/src/styles.scss | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src-ui/src/styles.scss b/src-ui/src/styles.scss index 244fba8bb..fde841ffb 100644 --- a/src-ui/src/styles.scss +++ b/src-ui/src/styles.scss @@ -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);