From 3ffd2a745b4380df637f96e6ce855373112ddb0d Mon Sep 17 00:00:00 2001 From: tooomm Date: Thu, 19 May 2022 22:05:43 +0200 Subject: [PATCH 1/9] update heading levels for v1.7.0 --- docs/changelog.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 9ba2f9aa0..9d35ee050 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -70,12 +70,12 @@ ## paperless-ngx 1.7.0 -Breaking Changes +### Breaking Changes - `PAPERLESS_URL` is now required when using a reverse proxy. See [\#674](https://github.com/paperless-ngx/paperless-ngx/pull/674). -Features +### Features - Allow setting more than one tag in mail rules [\@jonasc](https://github.com/jonasc) (\#270) @@ -107,7 +107,7 @@ Features - Parse dates when entered without separators [\@GruberViktor](https://github.com/gruberviktor) (\#250). -Bug Fixes +### Bug Fixes - add \"localhost\" to ALLOWED_HOSTS [\@gador](https://github.com/gador) (\#700). @@ -155,7 +155,7 @@ Bug Fixes - Fix: Include excluded items in dropdown count [\@shamoon](https://github.com/shamoon) (\#263). -Translation +### Translation - [\@miku323](https://github.com/miku323) contributed to Slovenian translation. @@ -168,7 +168,7 @@ Translation - [\@Prominence](https://github.com/Prominence) contributed to Belarusian translation. -Documentation +### Documentation - Fix: scanners table [\@qcasey](https://github.com/qcasey) (\#690). - Add [PAPERLESS\_URL]{.title-ref} env variable & CSRF var @@ -180,7 +180,7 @@ Documentation - Fix minor sphinx errors [\@shamoon](https://github.com/shamoon) (\#322). -Maintenance +### Maintenance - Add `PAPERLESS_URL` env variable & CSRF var [\@shamoon](https://github.com/shamoon) (\#674). From ce3f6837e97fd669b21bf9bfb2d5d6f729af9ca5 Mon Sep 17 00:00:00 2001 From: tooomm Date: Thu, 19 May 2022 23:12:40 +0200 Subject: [PATCH 2/9] Link issues, capitalization and minor fixes --- docs/changelog.md | 174 +++++++++++++++++++++++----------------------- 1 file changed, 87 insertions(+), 87 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 9d35ee050..319592b5d 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -17,7 +17,7 @@ ### Bug Fixes - Feature / fix saved view \& sort field query params [\@shamoon](https://github.com/shamoon) ([\#881](https://github.com/paperless-ngx/paperless-ngx/pull/881)) -- mobile friendlier manage pages [\@shamoon](https://github.com/shamoon) ([\#873](https://github.com/paperless-ngx/paperless-ngx/pull/873)) +- Mobile friendlier manage pages [\@shamoon](https://github.com/shamoon) ([\#873](https://github.com/paperless-ngx/paperless-ngx/pull/873)) - Add timeout to healthcheck [\@shamoon](https://github.com/shamoon) ([\#880](https://github.com/paperless-ngx/paperless-ngx/pull/880)) - Always accept yyyy-mm-dd date inputs [\@shamoon](https://github.com/shamoon) ([\#864](https://github.com/paperless-ngx/paperless-ngx/pull/864)) - Fix local Docker image building [\@stumpylog](https://github.com/stumpylog) ([\#849](https://github.com/paperless-ngx/paperless-ngx/pull/849)) @@ -78,129 +78,129 @@ ### Features - Allow setting more than one tag in mail rules - [\@jonasc](https://github.com/jonasc) (\#270) -- global drag\'n\'drop [\@shamoon](https://github.com/shamoon) - (\#283). + [\@jonasc](https://github.com/jonasc) ([\#270](https://github.com/paperless-ngx/paperless-ngx/pull/270)) +- Global drag\'n\'drop [\@shamoon](https://github.com/shamoon) + ([\#283](https://github.com/paperless-ngx/paperless-ngx/pull/283)) - Fix: download buttons should disable while waiting - [\@shamoon](https://github.com/shamoon) (\#630). -- Update checker [\@shamoon](https://github.com/shamoon) (\#591). + [\@shamoon](https://github.com/shamoon) ([\#630](https://github.com/paperless-ngx/paperless-ngx/pull/630)) +- Update checker [\@shamoon](https://github.com/shamoon) ([\#591](https://github.com/paperless-ngx/paperless-ngx/pull/591)) - Show prompt on password-protected pdfs - [\@shamoon](https://github.com/shamoon) (\#564). + [\@shamoon](https://github.com/shamoon) ([\#564](https://github.com/paperless-ngx/paperless-ngx/pull/564)) - Filtering query params aka browser navigation for filtering - [\@shamoon](https://github.com/shamoon) (\#540). + [\@shamoon](https://github.com/shamoon) ([\#540](https://github.com/paperless-ngx/paperless-ngx/pull/540)) - Clickable tags in dashboard widgets - [\@shamoon](https://github.com/shamoon) (\#515). + [\@shamoon](https://github.com/shamoon) ([\#515](https://github.com/paperless-ngx/paperless-ngx/pull/515)) - Add bottom pagination [\@shamoon](https://github.com/shamoon) - (\#372). + ([\#372](https://github.com/paperless-ngx/paperless-ngx/pull/372)) - Feature barcode splitter [\@gador](https://github.com/gador) - (\#532). -- App loading screen [\@shamoon](https://github.com/shamoon) (\#298). + ([\#532](https://github.com/paperless-ngx/paperless-ngx/pull/532)) +- App loading screen [\@shamoon](https://github.com/shamoon) ([\#298](https://github.com/paperless-ngx/paperless-ngx/pull/298)) - Use progress bar for delayed buttons - [\@shamoon](https://github.com/shamoon) (\#415). + [\@shamoon](https://github.com/shamoon) ([\#415](https://github.com/paperless-ngx/paperless-ngx/pull/415)) - Add minimum length for documents text filter - [\@shamoon](https://github.com/shamoon) (\#401). + [\@shamoon](https://github.com/shamoon) ([\#401](https://github.com/paperless-ngx/paperless-ngx/pull/401)) - Added nav buttons in the document detail view - [\@GruberViktor](https://github.com/gruberviktor) (\#273). + [\@GruberViktor](https://github.com/gruberviktor) ([\#273](https://github.com/paperless-ngx/paperless-ngx/pull/273)) - Improve date keyboard input [\@shamoon](https://github.com/shamoon) - (\#253). -- Color theming [\@shamoon](https://github.com/shamoon) (\#243). + ([\#253](https://github.com/paperless-ngx/paperless-ngx/pull/253)) +- Color theming [\@shamoon](https://github.com/shamoon) ([\#243](https://github.com/paperless-ngx/paperless-ngx/pull/243)) - Parse dates when entered without separators - [\@GruberViktor](https://github.com/gruberviktor) (\#250). + [\@GruberViktor](https://github.com/gruberviktor) ([\#250](https://github.com/paperless-ngx/paperless-ngx/pull/250)) ### Bug Fixes -- add \"localhost\" to ALLOWED_HOSTS - [\@gador](https://github.com/gador) (\#700). -- Fix: scanners table [\@qcasey](https://github.com/qcasey) (\#690). +- Add \"localhost\" to ALLOWED_HOSTS + [\@gador](https://github.com/gador) ([\#700](https://github.com/paperless-ngx/paperless-ngx/pull/700)) +- Fix: scanners table [\@qcasey](https://github.com/qcasey) ([\#690](https://github.com/paperless-ngx/paperless-ngx/pull/690)) - Adds wait for file before consuming - [\@stumpylog](https://github.com/stumpylog) (\#483). + [\@stumpylog](https://github.com/stumpylog) ([\#483](https://github.com/paperless-ngx/paperless-ngx/pull/483)) - Fix: frontend document editing erases time data - [\@shamoon](https://github.com/shamoon) (\#654). + [\@shamoon](https://github.com/shamoon) ([\#654](https://github.com/paperless-ngx/paperless-ngx/pull/654)) - Increase length of SavedViewFilterRule - [\@stumpylog](https://github.com/stumpylog) (\#612). + [\@stumpylog](https://github.com/stumpylog) ([\#612](https://github.com/paperless-ngx/paperless-ngx/pull/612)) - Fixes attachment filename matching during mail fetching - [\@stumpylog](https://github.com/stumpylog) (\#680). + [\@stumpylog](https://github.com/stumpylog) ([\#680](https://github.com/paperless-ngx/paperless-ngx/pull/680)) - Add `PAPERLESS_URL` env variable & CSRF var - [\@shamoon](https://github.com/shamoon) (\#674). + [\@shamoon](https://github.com/shamoon) ([\#674](https://github.com/paperless-ngx/paperless-ngx/discussions/674)) - Fix: download buttons should disable while waiting - [\@shamoon](https://github.com/shamoon) (\#630). + [\@shamoon](https://github.com/shamoon) ([\#630](https://github.com/paperless-ngx/paperless-ngx/pull/630)) - Fixes downloaded filename, add more consumer ignore settings - [\@stumpylog](https://github.com/stumpylog) (\#599). + [\@stumpylog](https://github.com/stumpylog) ([\#599](https://github.com/paperless-ngx/paperless-ngx/pull/599)) - FIX BUG: case-sensitive matching was not possible - [\@danielBreitlauch](https://github.com/danielbreitlauch) (\#594). -- uses shutil.move instead of rename - [\@gador](https://github.com/gador) (\#617). + [\@danielBreitlauch](https://github.com/danielbreitlauch) ([\#594](https://github.com/paperless-ngx/paperless-ngx/pull/594)) +- Uses shutil.move instead of rename + [\@gador](https://github.com/gador) ([\#617](https://github.com/paperless-ngx/paperless-ngx/pull/617)) - Fix npm deps 01.02.22 2 [\@shamoon](https://github.com/shamoon) - (\#610). + ([\#610](https://github.com/paperless-ngx/paperless-ngx/discussions/610)) - Fix npm dependencies 01.02.22 - [\@shamoon](https://github.com/shamoon) (\#600). -- fix issue 416: implement PAPERLESS_OCR_MAX_IMAGE_PIXELS - [\@hacker-h](https://github.com/hacker-h) (\#441). -- fix: exclude cypress from build in Dockerfile - [\@FrankStrieter](https://github.com/FrankStrieter) (\#526). + [\@shamoon](https://github.com/shamoon) ([\#600](https://github.com/paperless-ngx/paperless-ngx/pull/600)) +- Fix issue 416: implement `PAPERLESS_OCR_MAX_IMAGE_PIXELS` + [\@hacker-h](https://github.com/hacker-h) ([\#441](https://github.com/paperless-ngx/paperless-ngx/pull/441)) +- Fix: exclude cypress from build in Dockerfile + [\@FrankStrieter](https://github.com/FrankStrieter) ([\#526](https://github.com/paperless-ngx/paperless-ngx/pull/526)) - Corrections to pass pre-commit hooks - [\@schnuffle](https://github.com/schnuffle) (\#454). + [\@schnuffle](https://github.com/schnuffle) ([\#454](https://github.com/paperless-ngx/paperless-ngx/pull/454)) - Fix 311 unable to click checkboxes in document list - [\@shamoon](https://github.com/shamoon) (\#313). + [\@shamoon](https://github.com/shamoon) ([\#313](https://github.com/paperless-ngx/paperless-ngx/pull/313)) - Fix imap tools bug [\@stumpylog](https://github.com/stumpylog) - (\#393). + ([\#393](https://github.com/paperless-ngx/paperless-ngx/pull/393)) - Fix filterable dropdown buttons arent translated - [\@shamoon](https://github.com/shamoon) (\#366). + [\@shamoon](https://github.com/shamoon) ([\#366](https://github.com/paperless-ngx/paperless-ngx/pull/366)) - Fix 224: \"Auto-detected date is day before receipt date\" - [\@a17t](https://github.com/a17t) (\#246). + [\@a17t](https://github.com/a17t) ([\#246](https://github.com/paperless-ngx/paperless-ngx/pull/246)) - Fix minor sphinx errors [\@shamoon](https://github.com/shamoon) - (\#322). + ([\#322](https://github.com/paperless-ngx/paperless-ngx/pull/322)) - Fix page links hidden [\@shamoon](https://github.com/shamoon) - (\#314). + ([\#314](https://github.com/paperless-ngx/paperless-ngx/pull/314)) - Fix: Include excluded items in dropdown count - [\@shamoon](https://github.com/shamoon) (\#263). + [\@shamoon](https://github.com/shamoon) ([\#263](https://github.com/paperless-ngx/paperless-ngx/pull/263)) ### Translation - [\@miku323](https://github.com/miku323) contributed to Slovenian - translation. + translation - [\@FaintGhost](https://github.com/FaintGhost) contributed to Chinese - Simplified translation. + Simplified translation - [\@DarkoBG79](https://github.com/DarkoBG79) contributed to Serbian - translation. + translation - [Kemal Secer](https://crowdin.com/profile/kemal.secer) contributed - to Turkish translation. + to Turkish translation - [\@Prominence](https://github.com/Prominence) contributed to - Belarusian translation. + Belarusian translation ### Documentation -- Fix: scanners table [\@qcasey](https://github.com/qcasey) (\#690). -- Add [PAPERLESS\_URL]{.title-ref} env variable & CSRF var - [\@shamoon](https://github.com/shamoon) (\#674). +- Fix: scanners table [\@qcasey](https://github.com/qcasey) ([\#690](https://github.com/paperless-ngx/paperless-ngx/pull/690)) +- Add `PAPERLESS_URL` env variable & CSRF var + [\@shamoon](https://github.com/shamoon) ([\#674](https://github.com/paperless-ngx/paperless-ngx/pull/674)) - Fixes downloaded filename, add more consumer ignore settings - [\@stumpylog](https://github.com/stumpylog) (\#599). -- fix issue 416: implement `PAPERLESS_OCR_MAX_IMAGE_PIXELS` - [\@hacker-h](https://github.com/hacker-h) (\#441). + [\@stumpylog](https://github.com/stumpylog) ([\#599](https://github.com/paperless-ngx/paperless-ngx/pull/599)) +- Fix issue 416: implement `PAPERLESS_OCR_MAX_IMAGE_PIXELS` + [\@hacker-h](https://github.com/hacker-h) ([\#441](https://github.com/paperless-ngx/paperless-ngx/pull/441)) - Fix minor sphinx errors [\@shamoon](https://github.com/shamoon) - (\#322). + ([\#322](https://github.com/paperless-ngx/paperless-ngx/pull/322)) ### Maintenance - Add `PAPERLESS_URL` env variable & CSRF var - [\@shamoon](https://github.com/shamoon) (\#674). + [\@shamoon](https://github.com/shamoon) ([\#674](https://github.com/paperless-ngx/paperless-ngx/pull/674)) - Chore: Implement release-drafter action for Changelogs - [\@qcasey](https://github.com/qcasey) (\#669). -- Chore: Add CODEOWNERS [\@qcasey](https://github.com/qcasey) (\#667). + [\@qcasey](https://github.com/qcasey) ([\#669](https://github.com/paperless-ngx/paperless-ngx/pull/669)) +- Chore: Add CODEOWNERS [\@qcasey](https://github.com/qcasey) ([\#667](https://github.com/paperless-ngx/paperless-ngx/pull/667)) - Support docker-compose v2 in install - [\@stumpylog](https://github.com/stumpylog) (\#611). + [\@stumpylog](https://github.com/stumpylog) ([\#611](https://github.com/paperless-ngx/paperless-ngx/pull/611)) - Add Belarusian localization [\@shamoon](https://github.com/shamoon) - (\#588). + ([\#588](https://github.com/paperless-ngx/paperless-ngx/pull/588)) - Add Turkish localization [\@shamoon](https://github.com/shamoon) - (\#536). + ([\#536](https://github.com/paperless-ngx/paperless-ngx/pull/536)) - Add Serbian localization [\@shamoon](https://github.com/shamoon) - (\#504). + ([\#504](https://github.com/paperless-ngx/paperless-ngx/pull/504)) - Create PULL_REQUEST_TEMPLATE.md - [\@shamoon](https://github.com/shamoon) (\#304). + [\@shamoon](https://github.com/shamoon) ([\#304](https://github.com/paperless-ngx/paperless-ngx/pull/304)) - Add Chinese localization [\@shamoon](https://github.com/shamoon) - (\#247). + ([\#247](https://github.com/paperless-ngx/paperless-ngx/pull/247)) - Add Slovenian language for frontend - [\@shamoon](https://github.com/shamoon) (\#315). + [\@shamoon](https://github.com/shamoon) ([\#315](https://github.com/paperless-ngx/paperless-ngx/pull/315)) ## paperless-ngx 1.6.0 @@ -216,46 +216,46 @@ include: - Updated Python and Angular dependencies. - Dropped support for Python 3.7. - Dropped support for Ansible playbooks (thanks - [\@slankes](https://github.com/slankes) \#109). If someone would - like to continue supporting them, please see the [ansible + [\@slankes](https://github.com/slankes) [\#109](https://github.com/paperless-ngx/paperless-ngx/pull/109)). If someone would + like to continue supporting them, please see our [ansible repo](https://github.com/paperless-ngx/paperless-ngx-ansible). - Python code is now required to use Black formatting (thanks - [\@kpj](https://github.com/kpj) \#168). + [\@kpj](https://github.com/kpj) [\#168](https://github.com/paperless-ngx/paperless-ngx/pull/168)). - [\@tribut](https://github.com/tribut) added support for a custom SSO - logout redirect (jonaswinkler\#1258). See + logout redirect ([jonaswinkler\#1258](https://github.com/jonaswinkler/paperless-ng/pull/1258)). See `PAPERLESS_LOGOUT_REDIRECT_URL`. - [\@shamoon](https://github.com/shamoon) added a loading indicator - when document list is reloading (jonaswinkler\#1297). + when document list is reloading ([jonaswinkler\#1297](https://github.com/jonaswinkler/paperless-ng/pull/1297)). - [\@shamoon](https://github.com/shamoon) improved the PDF viewer on - mobile (\#2). + mobile ([\#2](https://github.com/paperless-ngx/paperless-ngx/pull/2)). - [\@shamoon](https://github.com/shamoon) added \'any\' / \'all\' and - \'not\' filtering with tags (\#10). + \'not\' filtering with tags ([\#10](https://github.com/paperless-ngx/paperless-ngx/pull/10)). - [\@shamoon](https://github.com/shamoon) added warnings for unsaved - changes, with smart edit buttons (\#13). + changes, with smart edit buttons ([\#13](https://github.com/paperless-ngx/paperless-ngx/pull/13)). - [\@benjaminfrank](https://github.com/benjaminfrank) enabled a - non-root access to port 80 via systemd (\#18). + non-root access to port 80 via systemd ([\#18](https://github.com/paperless-ngx/paperless-ngx/pull/18)). - [\@tribut](https://github.com/tribut) added simple \"delete to - trash\" functionality (\#24). See `PAPERLESS_TRASH_DIR`. + trash\" functionality ([\#24](https://github.com/paperless-ngx/paperless-ngx/pull/24)). See `PAPERLESS_TRASH_DIR`. - [\@amenk](https://github.com/amenk) fixed the search box overlay - menu on mobile (\#32). + menu on mobile ([\#32](https://github.com/paperless-ngx/paperless-ngx/pull/32)). - [\@dblitt](https://github.com/dblitt) updated the login form to not - auto-capitalize usernames (\#36). + auto-capitalize usernames ([\#36](https://github.com/paperless-ngx/paperless-ngx/pull/36)). - [\@evilsidekick293](https://github.com/evilsidekick293) made the - worker timeout configurable (\#37). See `PAPERLESS_WORKER_TIMEOUT`. + worker timeout configurable ([\#37](https://github.com/paperless-ngx/paperless-ngx/pull/37)). See `PAPERLESS_WORKER_TIMEOUT`. - [\@Nicarim](https://github.com/Nicarim) fixed downloads of UTF-8 - formatted documents in Firefox (\#56). + formatted documents in Firefox ([\#56](https://github.com/paperless-ngx/paperless-ngx/pull/56)). - [\@mweimerskirch](https://github.com/mweimerskirch) sorted the - language dropdown by locale (\#78). + language dropdown by locale ([\#78](https://github.com/paperless-ngx/paperless-ngx/issues/78)). - [\@mweimerskirch](https://github.com/mweimerskirch) enabled the - Czech (\#83) and Danish (\#84) translations. + Czech ([\#83](https://github.com/paperless-ngx/paperless-ngx/pull/83)) and Danish ([\#84](https://github.com/paperless-ngx/paperless-ngx/pull/84)) translations. - [\@cschmatzler](https://github.com/cschmatzler) enabled specifying - the webserver port (\#124). See `PAPERLESS_PORT`. + the webserver port ([\#124](https://github.com/paperless-ngx/paperless-ngx/pull/124)). See `PAPERLESS_PORT`. - [\@muellermartin](https://github.com/muellermartin) fixed an error - when uploading transparent PNGs (\#133). + when uploading transparent PNGs ([\#133](https://github.com/paperless-ngx/paperless-ngx/pull/133)). - [\@shamoon](https://github.com/shamoon) created a slick new logo - (\#165). + ([\#165](https://github.com/paperless-ngx/paperless-ngx/pull/165)). - [\@tim-vogel](https://github.com/tim-vogel) fixed exports missing - groups (\#193). + groups ([\#193](https://github.com/paperless-ngx/paperless-ngx/pull/193)). Known issues: From 5a809d7e312da8d4351229d4fe5c960182231c24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20R=C3=BCmpelein?= Date: Wed, 25 May 2022 19:22:50 +0200 Subject: [PATCH 3/9] Add first draft implementation, test broken. --- src/paperless_mail/mail.py | 13 ++++++++ src/paperless_mail/models.py | 1 + src/paperless_mail/tests/test_mail.py | 43 ++++++++++++++++++++++++++- 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/paperless_mail/mail.py b/src/paperless_mail/mail.py index 67cc22130..fefcbda5e 100644 --- a/src/paperless_mail/mail.py +++ b/src/paperless_mail/mail.py @@ -62,6 +62,17 @@ class FlagMailAction(BaseMailAction): M.flag(message_uids, [MailMessageFlags.FLAGGED], True) +class TagMailAction(BaseMailAction): + def __init__(self, parameter): + self.keyword = parameter + + def get_criteria(self): + return {"no_keyword": self.keyword} + + def post_consume(self, M: MailBox, message_uids, parameter): + M.flag(message_uids, [self.keyword], True) + + def get_rule_action(rule): if rule.action == MailRule.MailAction.FLAG: return FlagMailAction() @@ -71,6 +82,8 @@ def get_rule_action(rule): return MoveMailAction() elif rule.action == MailRule.MailAction.MARK_READ: return MarkReadMailAction() + elif rule.action == MailRule.MailAction.TAG: + return TagMailAction(rule.action_parameter) else: raise NotImplementedError("Unknown action.") # pragma: nocover diff --git a/src/paperless_mail/models.py b/src/paperless_mail/models.py index 4e90197b7..4c0a1a557 100644 --- a/src/paperless_mail/models.py +++ b/src/paperless_mail/models.py @@ -65,6 +65,7 @@ class MailRule(models.Model): MOVE = 2, _("Move to specified folder") MARK_READ = 3, _("Mark as read, don't process read mails") FLAG = 4, _("Flag the mail, don't process flagged mails") + TAG = 5, _("Tag the mail with specified tag, don't process tagged mails") class TitleSource(models.IntegerChoices): FROM_SUBJECT = 1, _("Use subject as title") diff --git a/src/paperless_mail/tests/test_mail.py b/src/paperless_mail/tests/test_mail.py index 24014b4dc..b275be360 100644 --- a/src/paperless_mail/tests/test_mail.py +++ b/src/paperless_mail/tests/test_mail.py @@ -4,7 +4,7 @@ import os import random import uuid from collections import namedtuple -from typing import ContextManager +from typing import ContextManager, Callable from typing import List from typing import Union from unittest import mock @@ -96,6 +96,18 @@ class BogusMailBox(ContextManager): if "UNFLAGGED" in criteria: msg = filter(lambda m: not m.flagged, msg) + if "NO_KEYWORD" in criteria: + tag: str = criteria[criteria.index("NO_KEYWORD") + 1].strip('"') + print(f"selected tag is {tag}.") + for m in msg: + print(f"Message with id {m.uid} has tags {','.join(m.flags)}") + msg = filter(lambda m: tag not in m.flags, msg) + + if "KEYWORD" in criteria: + tag = criteria[criteria.index("KEYWORD") + 1].strip('"') + print(f"selected tag is {tag}.") + msg = filter(lambda m: tag in m.flags, msg) + return list(msg) def delete(self, uid_list): @@ -130,6 +142,7 @@ def create_message( from_: str = "noone@mail.com", seen: bool = False, flagged: bool = False, + processed: bool = False, ) -> MailMessage: email_msg = email.message.EmailMessage() # TODO: This does NOT set the UID @@ -176,6 +189,10 @@ def create_message( imap_msg.seen = seen imap_msg.flagged = flagged + # Allows to test for both unset tags, and explicitly 'false' ones. + if processed: + imap_msg._raw_flag_data.append("+FLAGS (processed)".encode()) + return imap_msg @@ -225,6 +242,7 @@ class TestMail(DirectoriesMixin, TestCase): body="from my favorite electronic store", seen=False, flagged=True, + processed=True ), ) self.bogus_mailbox.messages.append( @@ -571,6 +589,29 @@ class TestMail(DirectoriesMixin, TestCase): self.assertEqual(len(self.bogus_mailbox.messages), 2) self.assertEqual(len(self.bogus_mailbox.messages_spam), 1) + def test_handle_mail_account_tag(self): + account = MailAccount.objects.create( + name="test", + imap_server="", + username="admin", + password="secret", + ) + + _ = MailRule.objects.create( + name="testrule", + account=account, + action=MailRule.MailAction.TAG, + action_parameter="processed", + ) + + self.assertEqual(len(self.bogus_mailbox.messages), 3) + self.assertEqual(self.async_task.call_count, 0) + self.assertEqual(len(self.bogus_mailbox.fetch("NO_KEYWORD processed", False)), 2) + self.mail_account_handler.handle_mail_account(account) + self.assertEqual(self.async_task.call_count, 2) + self.assertEqual(len(self.bogus_mailbox.fetch("NO_KEYWORD processed", False)), 0) + self.assertEqual(len(self.bogus_mailbox.messages), 3) + def test_error_login(self): account = MailAccount.objects.create( name="test", From 104a68451477845eda2229ac876a76ee7aa1d988 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20R=C3=BCmpelein?= Date: Wed, 25 May 2022 20:47:43 +0200 Subject: [PATCH 4/9] Revert all changes to tests, will need a more structured approach. --- src/paperless_mail/tests/test_mail.py | 43 +-------------------------- 1 file changed, 1 insertion(+), 42 deletions(-) diff --git a/src/paperless_mail/tests/test_mail.py b/src/paperless_mail/tests/test_mail.py index b275be360..24014b4dc 100644 --- a/src/paperless_mail/tests/test_mail.py +++ b/src/paperless_mail/tests/test_mail.py @@ -4,7 +4,7 @@ import os import random import uuid from collections import namedtuple -from typing import ContextManager, Callable +from typing import ContextManager from typing import List from typing import Union from unittest import mock @@ -96,18 +96,6 @@ class BogusMailBox(ContextManager): if "UNFLAGGED" in criteria: msg = filter(lambda m: not m.flagged, msg) - if "NO_KEYWORD" in criteria: - tag: str = criteria[criteria.index("NO_KEYWORD") + 1].strip('"') - print(f"selected tag is {tag}.") - for m in msg: - print(f"Message with id {m.uid} has tags {','.join(m.flags)}") - msg = filter(lambda m: tag not in m.flags, msg) - - if "KEYWORD" in criteria: - tag = criteria[criteria.index("KEYWORD") + 1].strip('"') - print(f"selected tag is {tag}.") - msg = filter(lambda m: tag in m.flags, msg) - return list(msg) def delete(self, uid_list): @@ -142,7 +130,6 @@ def create_message( from_: str = "noone@mail.com", seen: bool = False, flagged: bool = False, - processed: bool = False, ) -> MailMessage: email_msg = email.message.EmailMessage() # TODO: This does NOT set the UID @@ -189,10 +176,6 @@ def create_message( imap_msg.seen = seen imap_msg.flagged = flagged - # Allows to test for both unset tags, and explicitly 'false' ones. - if processed: - imap_msg._raw_flag_data.append("+FLAGS (processed)".encode()) - return imap_msg @@ -242,7 +225,6 @@ class TestMail(DirectoriesMixin, TestCase): body="from my favorite electronic store", seen=False, flagged=True, - processed=True ), ) self.bogus_mailbox.messages.append( @@ -589,29 +571,6 @@ class TestMail(DirectoriesMixin, TestCase): self.assertEqual(len(self.bogus_mailbox.messages), 2) self.assertEqual(len(self.bogus_mailbox.messages_spam), 1) - def test_handle_mail_account_tag(self): - account = MailAccount.objects.create( - name="test", - imap_server="", - username="admin", - password="secret", - ) - - _ = MailRule.objects.create( - name="testrule", - account=account, - action=MailRule.MailAction.TAG, - action_parameter="processed", - ) - - self.assertEqual(len(self.bogus_mailbox.messages), 3) - self.assertEqual(self.async_task.call_count, 0) - self.assertEqual(len(self.bogus_mailbox.fetch("NO_KEYWORD processed", False)), 2) - self.mail_account_handler.handle_mail_account(account) - self.assertEqual(self.async_task.call_count, 2) - self.assertEqual(len(self.bogus_mailbox.fetch("NO_KEYWORD processed", False)), 0) - self.assertEqual(len(self.bogus_mailbox.messages), 3) - def test_error_login(self): account = MailAccount.objects.create( name="test", From c90129957ebbb1dfe23e2ea152e43a230d080b20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20R=C3=BCmpelein?= Date: Thu, 26 May 2022 12:42:20 +0200 Subject: [PATCH 5/9] Make test work. --- src/paperless_mail/tests/test_mail.py | 43 +++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/paperless_mail/tests/test_mail.py b/src/paperless_mail/tests/test_mail.py index 24014b4dc..348876be2 100644 --- a/src/paperless_mail/tests/test_mail.py +++ b/src/paperless_mail/tests/test_mail.py @@ -1,5 +1,6 @@ import dataclasses import email.contentmanager +import imaplib import os import random import uuid @@ -96,6 +97,11 @@ class BogusMailBox(ContextManager): if "UNFLAGGED" in criteria: msg = filter(lambda m: not m.flagged, msg) + if "UNKEYWORD" in criteria: + tag = criteria[criteria.index("UNKEYWORD") + 1].strip("'") + # For custom-flags, we need to access the `_raw_flags` field, as calls to `.flags` get cached, thus breaking the test. + msg = filter(lambda m: "processed" not in parse_raw_tags_omit_cache(m), msg) + return list(msg) def delete(self, uid_list): @@ -109,6 +115,8 @@ class BogusMailBox(ContextManager): message.flagged = value if flag == MailMessageFlags.SEEN: message.seen = value + if flag == "processed": + message._raw_flag_data.append(f"+FLAGS (processed)".encode()) def move(self, uid_list, folder): if folder == "spam": @@ -130,6 +138,7 @@ def create_message( from_: str = "noone@mail.com", seen: bool = False, flagged: bool = False, + processed: bool = False, ) -> MailMessage: email_msg = email.message.EmailMessage() # TODO: This does NOT set the UID @@ -175,6 +184,8 @@ def create_message( imap_msg.seen = seen imap_msg.flagged = flagged + if processed: + imap_msg._raw_flag_data.append(f"+FLAGS (processed)".encode()) return imap_msg @@ -189,6 +200,13 @@ def fake_magic_from_buffer(buffer, mime=False): return "Some verbose file description" +def parse_raw_tags_omit_cache(m: MailMessage) -> List[str]: + raw_result: list[bytes] = [] + for rf in m._raw_flag_data: + raw_result.extend(imaplib.ParseFlags(rf)) + return [f.decode().strip() for f in raw_result] + + @mock.patch("paperless_mail.mail.magic.from_buffer", fake_magic_from_buffer) class TestMail(DirectoriesMixin, TestCase): def setUp(self): @@ -217,6 +235,7 @@ class TestMail(DirectoriesMixin, TestCase): body="cables", seen=True, flagged=False, + processed=False, ), ) self.bogus_mailbox.messages.append( @@ -225,6 +244,7 @@ class TestMail(DirectoriesMixin, TestCase): body="from my favorite electronic store", seen=False, flagged=True, + processed=True, ), ) self.bogus_mailbox.messages.append( @@ -571,6 +591,29 @@ class TestMail(DirectoriesMixin, TestCase): self.assertEqual(len(self.bogus_mailbox.messages), 2) self.assertEqual(len(self.bogus_mailbox.messages_spam), 1) + def test_handle_mail_account_tag(self): + account = MailAccount.objects.create( + name="test", + imap_server="", + username="admin", + password="secret", + ) + + _ = MailRule.objects.create( + name="testrule", + account=account, + action=MailRule.MailAction.TAG, + action_parameter="processed", + ) + + self.assertEqual(len(self.bogus_mailbox.messages), 3) + self.assertEqual(self.async_task.call_count, 0) + self.assertEqual(len(self.bogus_mailbox.fetch("UNKEYWORD processed", False)), 2) + self.mail_account_handler.handle_mail_account(account) + self.assertEqual(self.async_task.call_count, 2) + self.assertEqual(len(self.bogus_mailbox.fetch("UNKEYWORD processed", False)), 0) + self.assertEqual(len(self.bogus_mailbox.messages), 3) + def test_error_login(self): account = MailAccount.objects.create( name="test", From 080a23dd8ced7c2bc3d71c993b1e8af048db3cb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20R=C3=BCmpelein?= Date: Thu, 26 May 2022 12:42:29 +0200 Subject: [PATCH 6/9] Update docs. --- docs/usage_overview.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/usage_overview.rst b/docs/usage_overview.rst index d7cfb8250..a321afb93 100644 --- a/docs/usage_overview.rst +++ b/docs/usage_overview.rst @@ -161,6 +161,9 @@ These are as follows: will not consume flagged mails. * **Move to folder:** Moves consumed mails out of the way so that paperless wont consume them again. +* **Add custom Tag:** Adds a custom tag to mails with consumed documents (the IMAP + standard calls these "keywords"). Paperless will not consume mails already tagged. + Not all mail servers support this feature! .. caution:: From 0cc7765f2b9ca8780a3865b7255bb4b3c776852d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20R=C3=BCmpelein?= Date: Thu, 26 May 2022 17:40:11 +0200 Subject: [PATCH 7/9] Revert accidentally included changes. --- docs/changelog.md | 186 +++++++++++++++++++++++----------------------- 1 file changed, 93 insertions(+), 93 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 319592b5d..9ba2f9aa0 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -17,7 +17,7 @@ ### Bug Fixes - Feature / fix saved view \& sort field query params [\@shamoon](https://github.com/shamoon) ([\#881](https://github.com/paperless-ngx/paperless-ngx/pull/881)) -- Mobile friendlier manage pages [\@shamoon](https://github.com/shamoon) ([\#873](https://github.com/paperless-ngx/paperless-ngx/pull/873)) +- mobile friendlier manage pages [\@shamoon](https://github.com/shamoon) ([\#873](https://github.com/paperless-ngx/paperless-ngx/pull/873)) - Add timeout to healthcheck [\@shamoon](https://github.com/shamoon) ([\#880](https://github.com/paperless-ngx/paperless-ngx/pull/880)) - Always accept yyyy-mm-dd date inputs [\@shamoon](https://github.com/shamoon) ([\#864](https://github.com/paperless-ngx/paperless-ngx/pull/864)) - Fix local Docker image building [\@stumpylog](https://github.com/stumpylog) ([\#849](https://github.com/paperless-ngx/paperless-ngx/pull/849)) @@ -70,137 +70,137 @@ ## paperless-ngx 1.7.0 -### Breaking Changes +Breaking Changes - `PAPERLESS_URL` is now required when using a reverse proxy. See [\#674](https://github.com/paperless-ngx/paperless-ngx/pull/674). -### Features +Features - Allow setting more than one tag in mail rules - [\@jonasc](https://github.com/jonasc) ([\#270](https://github.com/paperless-ngx/paperless-ngx/pull/270)) -- Global drag\'n\'drop [\@shamoon](https://github.com/shamoon) - ([\#283](https://github.com/paperless-ngx/paperless-ngx/pull/283)) + [\@jonasc](https://github.com/jonasc) (\#270) +- global drag\'n\'drop [\@shamoon](https://github.com/shamoon) + (\#283). - Fix: download buttons should disable while waiting - [\@shamoon](https://github.com/shamoon) ([\#630](https://github.com/paperless-ngx/paperless-ngx/pull/630)) -- Update checker [\@shamoon](https://github.com/shamoon) ([\#591](https://github.com/paperless-ngx/paperless-ngx/pull/591)) + [\@shamoon](https://github.com/shamoon) (\#630). +- Update checker [\@shamoon](https://github.com/shamoon) (\#591). - Show prompt on password-protected pdfs - [\@shamoon](https://github.com/shamoon) ([\#564](https://github.com/paperless-ngx/paperless-ngx/pull/564)) + [\@shamoon](https://github.com/shamoon) (\#564). - Filtering query params aka browser navigation for filtering - [\@shamoon](https://github.com/shamoon) ([\#540](https://github.com/paperless-ngx/paperless-ngx/pull/540)) + [\@shamoon](https://github.com/shamoon) (\#540). - Clickable tags in dashboard widgets - [\@shamoon](https://github.com/shamoon) ([\#515](https://github.com/paperless-ngx/paperless-ngx/pull/515)) + [\@shamoon](https://github.com/shamoon) (\#515). - Add bottom pagination [\@shamoon](https://github.com/shamoon) - ([\#372](https://github.com/paperless-ngx/paperless-ngx/pull/372)) + (\#372). - Feature barcode splitter [\@gador](https://github.com/gador) - ([\#532](https://github.com/paperless-ngx/paperless-ngx/pull/532)) -- App loading screen [\@shamoon](https://github.com/shamoon) ([\#298](https://github.com/paperless-ngx/paperless-ngx/pull/298)) + (\#532). +- App loading screen [\@shamoon](https://github.com/shamoon) (\#298). - Use progress bar for delayed buttons - [\@shamoon](https://github.com/shamoon) ([\#415](https://github.com/paperless-ngx/paperless-ngx/pull/415)) + [\@shamoon](https://github.com/shamoon) (\#415). - Add minimum length for documents text filter - [\@shamoon](https://github.com/shamoon) ([\#401](https://github.com/paperless-ngx/paperless-ngx/pull/401)) + [\@shamoon](https://github.com/shamoon) (\#401). - Added nav buttons in the document detail view - [\@GruberViktor](https://github.com/gruberviktor) ([\#273](https://github.com/paperless-ngx/paperless-ngx/pull/273)) + [\@GruberViktor](https://github.com/gruberviktor) (\#273). - Improve date keyboard input [\@shamoon](https://github.com/shamoon) - ([\#253](https://github.com/paperless-ngx/paperless-ngx/pull/253)) -- Color theming [\@shamoon](https://github.com/shamoon) ([\#243](https://github.com/paperless-ngx/paperless-ngx/pull/243)) + (\#253). +- Color theming [\@shamoon](https://github.com/shamoon) (\#243). - Parse dates when entered without separators - [\@GruberViktor](https://github.com/gruberviktor) ([\#250](https://github.com/paperless-ngx/paperless-ngx/pull/250)) + [\@GruberViktor](https://github.com/gruberviktor) (\#250). -### Bug Fixes +Bug Fixes -- Add \"localhost\" to ALLOWED_HOSTS - [\@gador](https://github.com/gador) ([\#700](https://github.com/paperless-ngx/paperless-ngx/pull/700)) -- Fix: scanners table [\@qcasey](https://github.com/qcasey) ([\#690](https://github.com/paperless-ngx/paperless-ngx/pull/690)) +- add \"localhost\" to ALLOWED_HOSTS + [\@gador](https://github.com/gador) (\#700). +- Fix: scanners table [\@qcasey](https://github.com/qcasey) (\#690). - Adds wait for file before consuming - [\@stumpylog](https://github.com/stumpylog) ([\#483](https://github.com/paperless-ngx/paperless-ngx/pull/483)) + [\@stumpylog](https://github.com/stumpylog) (\#483). - Fix: frontend document editing erases time data - [\@shamoon](https://github.com/shamoon) ([\#654](https://github.com/paperless-ngx/paperless-ngx/pull/654)) + [\@shamoon](https://github.com/shamoon) (\#654). - Increase length of SavedViewFilterRule - [\@stumpylog](https://github.com/stumpylog) ([\#612](https://github.com/paperless-ngx/paperless-ngx/pull/612)) + [\@stumpylog](https://github.com/stumpylog) (\#612). - Fixes attachment filename matching during mail fetching - [\@stumpylog](https://github.com/stumpylog) ([\#680](https://github.com/paperless-ngx/paperless-ngx/pull/680)) + [\@stumpylog](https://github.com/stumpylog) (\#680). - Add `PAPERLESS_URL` env variable & CSRF var - [\@shamoon](https://github.com/shamoon) ([\#674](https://github.com/paperless-ngx/paperless-ngx/discussions/674)) + [\@shamoon](https://github.com/shamoon) (\#674). - Fix: download buttons should disable while waiting - [\@shamoon](https://github.com/shamoon) ([\#630](https://github.com/paperless-ngx/paperless-ngx/pull/630)) + [\@shamoon](https://github.com/shamoon) (\#630). - Fixes downloaded filename, add more consumer ignore settings - [\@stumpylog](https://github.com/stumpylog) ([\#599](https://github.com/paperless-ngx/paperless-ngx/pull/599)) + [\@stumpylog](https://github.com/stumpylog) (\#599). - FIX BUG: case-sensitive matching was not possible - [\@danielBreitlauch](https://github.com/danielbreitlauch) ([\#594](https://github.com/paperless-ngx/paperless-ngx/pull/594)) -- Uses shutil.move instead of rename - [\@gador](https://github.com/gador) ([\#617](https://github.com/paperless-ngx/paperless-ngx/pull/617)) + [\@danielBreitlauch](https://github.com/danielbreitlauch) (\#594). +- uses shutil.move instead of rename + [\@gador](https://github.com/gador) (\#617). - Fix npm deps 01.02.22 2 [\@shamoon](https://github.com/shamoon) - ([\#610](https://github.com/paperless-ngx/paperless-ngx/discussions/610)) + (\#610). - Fix npm dependencies 01.02.22 - [\@shamoon](https://github.com/shamoon) ([\#600](https://github.com/paperless-ngx/paperless-ngx/pull/600)) -- Fix issue 416: implement `PAPERLESS_OCR_MAX_IMAGE_PIXELS` - [\@hacker-h](https://github.com/hacker-h) ([\#441](https://github.com/paperless-ngx/paperless-ngx/pull/441)) -- Fix: exclude cypress from build in Dockerfile - [\@FrankStrieter](https://github.com/FrankStrieter) ([\#526](https://github.com/paperless-ngx/paperless-ngx/pull/526)) + [\@shamoon](https://github.com/shamoon) (\#600). +- fix issue 416: implement PAPERLESS_OCR_MAX_IMAGE_PIXELS + [\@hacker-h](https://github.com/hacker-h) (\#441). +- fix: exclude cypress from build in Dockerfile + [\@FrankStrieter](https://github.com/FrankStrieter) (\#526). - Corrections to pass pre-commit hooks - [\@schnuffle](https://github.com/schnuffle) ([\#454](https://github.com/paperless-ngx/paperless-ngx/pull/454)) + [\@schnuffle](https://github.com/schnuffle) (\#454). - Fix 311 unable to click checkboxes in document list - [\@shamoon](https://github.com/shamoon) ([\#313](https://github.com/paperless-ngx/paperless-ngx/pull/313)) + [\@shamoon](https://github.com/shamoon) (\#313). - Fix imap tools bug [\@stumpylog](https://github.com/stumpylog) - ([\#393](https://github.com/paperless-ngx/paperless-ngx/pull/393)) + (\#393). - Fix filterable dropdown buttons arent translated - [\@shamoon](https://github.com/shamoon) ([\#366](https://github.com/paperless-ngx/paperless-ngx/pull/366)) + [\@shamoon](https://github.com/shamoon) (\#366). - Fix 224: \"Auto-detected date is day before receipt date\" - [\@a17t](https://github.com/a17t) ([\#246](https://github.com/paperless-ngx/paperless-ngx/pull/246)) + [\@a17t](https://github.com/a17t) (\#246). - Fix minor sphinx errors [\@shamoon](https://github.com/shamoon) - ([\#322](https://github.com/paperless-ngx/paperless-ngx/pull/322)) + (\#322). - Fix page links hidden [\@shamoon](https://github.com/shamoon) - ([\#314](https://github.com/paperless-ngx/paperless-ngx/pull/314)) + (\#314). - Fix: Include excluded items in dropdown count - [\@shamoon](https://github.com/shamoon) ([\#263](https://github.com/paperless-ngx/paperless-ngx/pull/263)) + [\@shamoon](https://github.com/shamoon) (\#263). -### Translation +Translation - [\@miku323](https://github.com/miku323) contributed to Slovenian - translation + translation. - [\@FaintGhost](https://github.com/FaintGhost) contributed to Chinese - Simplified translation + Simplified translation. - [\@DarkoBG79](https://github.com/DarkoBG79) contributed to Serbian - translation + translation. - [Kemal Secer](https://crowdin.com/profile/kemal.secer) contributed - to Turkish translation + to Turkish translation. - [\@Prominence](https://github.com/Prominence) contributed to - Belarusian translation + Belarusian translation. -### Documentation +Documentation -- Fix: scanners table [\@qcasey](https://github.com/qcasey) ([\#690](https://github.com/paperless-ngx/paperless-ngx/pull/690)) -- Add `PAPERLESS_URL` env variable & CSRF var - [\@shamoon](https://github.com/shamoon) ([\#674](https://github.com/paperless-ngx/paperless-ngx/pull/674)) +- Fix: scanners table [\@qcasey](https://github.com/qcasey) (\#690). +- Add [PAPERLESS\_URL]{.title-ref} env variable & CSRF var + [\@shamoon](https://github.com/shamoon) (\#674). - Fixes downloaded filename, add more consumer ignore settings - [\@stumpylog](https://github.com/stumpylog) ([\#599](https://github.com/paperless-ngx/paperless-ngx/pull/599)) -- Fix issue 416: implement `PAPERLESS_OCR_MAX_IMAGE_PIXELS` - [\@hacker-h](https://github.com/hacker-h) ([\#441](https://github.com/paperless-ngx/paperless-ngx/pull/441)) + [\@stumpylog](https://github.com/stumpylog) (\#599). +- fix issue 416: implement `PAPERLESS_OCR_MAX_IMAGE_PIXELS` + [\@hacker-h](https://github.com/hacker-h) (\#441). - Fix minor sphinx errors [\@shamoon](https://github.com/shamoon) - ([\#322](https://github.com/paperless-ngx/paperless-ngx/pull/322)) + (\#322). -### Maintenance +Maintenance - Add `PAPERLESS_URL` env variable & CSRF var - [\@shamoon](https://github.com/shamoon) ([\#674](https://github.com/paperless-ngx/paperless-ngx/pull/674)) + [\@shamoon](https://github.com/shamoon) (\#674). - Chore: Implement release-drafter action for Changelogs - [\@qcasey](https://github.com/qcasey) ([\#669](https://github.com/paperless-ngx/paperless-ngx/pull/669)) -- Chore: Add CODEOWNERS [\@qcasey](https://github.com/qcasey) ([\#667](https://github.com/paperless-ngx/paperless-ngx/pull/667)) + [\@qcasey](https://github.com/qcasey) (\#669). +- Chore: Add CODEOWNERS [\@qcasey](https://github.com/qcasey) (\#667). - Support docker-compose v2 in install - [\@stumpylog](https://github.com/stumpylog) ([\#611](https://github.com/paperless-ngx/paperless-ngx/pull/611)) + [\@stumpylog](https://github.com/stumpylog) (\#611). - Add Belarusian localization [\@shamoon](https://github.com/shamoon) - ([\#588](https://github.com/paperless-ngx/paperless-ngx/pull/588)) + (\#588). - Add Turkish localization [\@shamoon](https://github.com/shamoon) - ([\#536](https://github.com/paperless-ngx/paperless-ngx/pull/536)) + (\#536). - Add Serbian localization [\@shamoon](https://github.com/shamoon) - ([\#504](https://github.com/paperless-ngx/paperless-ngx/pull/504)) + (\#504). - Create PULL_REQUEST_TEMPLATE.md - [\@shamoon](https://github.com/shamoon) ([\#304](https://github.com/paperless-ngx/paperless-ngx/pull/304)) + [\@shamoon](https://github.com/shamoon) (\#304). - Add Chinese localization [\@shamoon](https://github.com/shamoon) - ([\#247](https://github.com/paperless-ngx/paperless-ngx/pull/247)) + (\#247). - Add Slovenian language for frontend - [\@shamoon](https://github.com/shamoon) ([\#315](https://github.com/paperless-ngx/paperless-ngx/pull/315)) + [\@shamoon](https://github.com/shamoon) (\#315). ## paperless-ngx 1.6.0 @@ -216,46 +216,46 @@ include: - Updated Python and Angular dependencies. - Dropped support for Python 3.7. - Dropped support for Ansible playbooks (thanks - [\@slankes](https://github.com/slankes) [\#109](https://github.com/paperless-ngx/paperless-ngx/pull/109)). If someone would - like to continue supporting them, please see our [ansible + [\@slankes](https://github.com/slankes) \#109). If someone would + like to continue supporting them, please see the [ansible repo](https://github.com/paperless-ngx/paperless-ngx-ansible). - Python code is now required to use Black formatting (thanks - [\@kpj](https://github.com/kpj) [\#168](https://github.com/paperless-ngx/paperless-ngx/pull/168)). + [\@kpj](https://github.com/kpj) \#168). - [\@tribut](https://github.com/tribut) added support for a custom SSO - logout redirect ([jonaswinkler\#1258](https://github.com/jonaswinkler/paperless-ng/pull/1258)). See + logout redirect (jonaswinkler\#1258). See `PAPERLESS_LOGOUT_REDIRECT_URL`. - [\@shamoon](https://github.com/shamoon) added a loading indicator - when document list is reloading ([jonaswinkler\#1297](https://github.com/jonaswinkler/paperless-ng/pull/1297)). + when document list is reloading (jonaswinkler\#1297). - [\@shamoon](https://github.com/shamoon) improved the PDF viewer on - mobile ([\#2](https://github.com/paperless-ngx/paperless-ngx/pull/2)). + mobile (\#2). - [\@shamoon](https://github.com/shamoon) added \'any\' / \'all\' and - \'not\' filtering with tags ([\#10](https://github.com/paperless-ngx/paperless-ngx/pull/10)). + \'not\' filtering with tags (\#10). - [\@shamoon](https://github.com/shamoon) added warnings for unsaved - changes, with smart edit buttons ([\#13](https://github.com/paperless-ngx/paperless-ngx/pull/13)). + changes, with smart edit buttons (\#13). - [\@benjaminfrank](https://github.com/benjaminfrank) enabled a - non-root access to port 80 via systemd ([\#18](https://github.com/paperless-ngx/paperless-ngx/pull/18)). + non-root access to port 80 via systemd (\#18). - [\@tribut](https://github.com/tribut) added simple \"delete to - trash\" functionality ([\#24](https://github.com/paperless-ngx/paperless-ngx/pull/24)). See `PAPERLESS_TRASH_DIR`. + trash\" functionality (\#24). See `PAPERLESS_TRASH_DIR`. - [\@amenk](https://github.com/amenk) fixed the search box overlay - menu on mobile ([\#32](https://github.com/paperless-ngx/paperless-ngx/pull/32)). + menu on mobile (\#32). - [\@dblitt](https://github.com/dblitt) updated the login form to not - auto-capitalize usernames ([\#36](https://github.com/paperless-ngx/paperless-ngx/pull/36)). + auto-capitalize usernames (\#36). - [\@evilsidekick293](https://github.com/evilsidekick293) made the - worker timeout configurable ([\#37](https://github.com/paperless-ngx/paperless-ngx/pull/37)). See `PAPERLESS_WORKER_TIMEOUT`. + worker timeout configurable (\#37). See `PAPERLESS_WORKER_TIMEOUT`. - [\@Nicarim](https://github.com/Nicarim) fixed downloads of UTF-8 - formatted documents in Firefox ([\#56](https://github.com/paperless-ngx/paperless-ngx/pull/56)). + formatted documents in Firefox (\#56). - [\@mweimerskirch](https://github.com/mweimerskirch) sorted the - language dropdown by locale ([\#78](https://github.com/paperless-ngx/paperless-ngx/issues/78)). + language dropdown by locale (\#78). - [\@mweimerskirch](https://github.com/mweimerskirch) enabled the - Czech ([\#83](https://github.com/paperless-ngx/paperless-ngx/pull/83)) and Danish ([\#84](https://github.com/paperless-ngx/paperless-ngx/pull/84)) translations. + Czech (\#83) and Danish (\#84) translations. - [\@cschmatzler](https://github.com/cschmatzler) enabled specifying - the webserver port ([\#124](https://github.com/paperless-ngx/paperless-ngx/pull/124)). See `PAPERLESS_PORT`. + the webserver port (\#124). See `PAPERLESS_PORT`. - [\@muellermartin](https://github.com/muellermartin) fixed an error - when uploading transparent PNGs ([\#133](https://github.com/paperless-ngx/paperless-ngx/pull/133)). + when uploading transparent PNGs (\#133). - [\@shamoon](https://github.com/shamoon) created a slick new logo - ([\#165](https://github.com/paperless-ngx/paperless-ngx/pull/165)). + (\#165). - [\@tim-vogel](https://github.com/tim-vogel) fixed exports missing - groups ([\#193](https://github.com/paperless-ngx/paperless-ngx/pull/193)). + groups (\#193). Known issues: From ac62bcb7baa6151c0054ee4891a869e487bbe2a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20R=C3=BCmpelein?= Date: Fri, 27 May 2022 22:51:32 +0200 Subject: [PATCH 8/9] Clear cache instead of working around it. --- src/paperless_mail/tests/test_mail.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/paperless_mail/tests/test_mail.py b/src/paperless_mail/tests/test_mail.py index 348876be2..2aaa588d6 100644 --- a/src/paperless_mail/tests/test_mail.py +++ b/src/paperless_mail/tests/test_mail.py @@ -1,6 +1,5 @@ import dataclasses import email.contentmanager -import imaplib import os import random import uuid @@ -99,8 +98,7 @@ class BogusMailBox(ContextManager): if "UNKEYWORD" in criteria: tag = criteria[criteria.index("UNKEYWORD") + 1].strip("'") - # For custom-flags, we need to access the `_raw_flags` field, as calls to `.flags` get cached, thus breaking the test. - msg = filter(lambda m: "processed" not in parse_raw_tags_omit_cache(m), msg) + msg = filter(lambda m: "processed" not in m.flags, msg) return list(msg) @@ -117,6 +115,7 @@ class BogusMailBox(ContextManager): message.seen = value if flag == "processed": message._raw_flag_data.append(f"+FLAGS (processed)".encode()) + MailMessage.flags.fget.cache_clear() def move(self, uid_list, folder): if folder == "spam": @@ -186,6 +185,7 @@ def create_message( imap_msg.flagged = flagged if processed: imap_msg._raw_flag_data.append(f"+FLAGS (processed)".encode()) + MailMessage.flags.fget.cache_clear() return imap_msg @@ -200,13 +200,6 @@ def fake_magic_from_buffer(buffer, mime=False): return "Some verbose file description" -def parse_raw_tags_omit_cache(m: MailMessage) -> List[str]: - raw_result: list[bytes] = [] - for rf in m._raw_flag_data: - raw_result.extend(imaplib.ParseFlags(rf)) - return [f.decode().strip() for f in raw_result] - - @mock.patch("paperless_mail.mail.magic.from_buffer", fake_magic_from_buffer) class TestMail(DirectoriesMixin, TestCase): def setUp(self): From 898564c8d84d915a8f30f520bed0ce80fb48558e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20R=C3=BCmpelein?= Date: Sun, 29 May 2022 15:22:50 +0200 Subject: [PATCH 9/9] Add migration for new rule. --- .../migrations/0015_alter_mailrule_action.py | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/paperless_mail/migrations/0015_alter_mailrule_action.py diff --git a/src/paperless_mail/migrations/0015_alter_mailrule_action.py b/src/paperless_mail/migrations/0015_alter_mailrule_action.py new file mode 100644 index 000000000..62a44e6aa --- /dev/null +++ b/src/paperless_mail/migrations/0015_alter_mailrule_action.py @@ -0,0 +1,28 @@ +# Generated by Django 4.0.4 on 2022-05-29 13:21 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("paperless_mail", "0014_alter_mailrule_action"), + ] + + operations = [ + migrations.AlterField( + model_name="mailrule", + name="action", + field=models.PositiveIntegerField( + choices=[ + (1, "Delete"), + (2, "Move to specified folder"), + (3, "Mark as read, don't process read mails"), + (4, "Flag the mail, don't process flagged mails"), + (5, "Tag the mail with specified tag, don't process tagged mails"), + ], + default=3, + verbose_name="action", + ), + ), + ]