From 85870c896fb20fe6a2036cd3fab6db429dc31058 Mon Sep 17 00:00:00 2001 From: Joe Date: Wed, 3 Feb 2021 20:58:11 -0500 Subject: [PATCH] changes repo to customized solution --- CHANGELOG.md | 14 +++++ CHANGELOG.rst | 93 ------------------------------- Makefile | 51 +++++++++++++++++ django_mailbox/transports/imap.py | 27 +++++++++ pyproject.toml | 2 +- rtd_requirements.txt | 2 - test_requirements.txt | 3 - tox.ini | 36 ------------ 8 files changed, 93 insertions(+), 135 deletions(-) create mode 100644 CHANGELOG.md delete mode 100644 CHANGELOG.rst create mode 100644 Makefile delete mode 100644 rtd_requirements.txt delete mode 100644 test_requirements.txt delete mode 100644 tox.ini diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..ee2596d --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,14 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +[Also based on](https://github.com/conventional-changelog/standard-version/blob/master/CHANGELOG.md) so decending. + +## [0.1.0] - 2021-02-03 +### Added +- bot - adds changelog + +### Changed +- changes repo to customized solution + diff --git a/CHANGELOG.rst b/CHANGELOG.rst deleted file mode 100644 index 208bf4f..0000000 --- a/CHANGELOG.rst +++ /dev/null @@ -1,93 +0,0 @@ -Changelog -========= - -4.8.1 ------ - -* Add missing migration - -4.8.0 ------ - -* ```django_mailbox.models.Mailbox.get_new_mail``` become generator -* Added to ```django_mailbox.models.Message.mailbox``` in-memory caches of result -* Added to command ```processincomingmessage``` argument to pass mailbox name -* Improved tests, especially different Django & Python version - -4.6.1 ------ - -* Add Django 2.0 support - - - Add on_delete=models.CASCADE in models & migrations - - Add Django 2.0 to tests matrices - -4.4 ---- - -* Adds Django 1.8 support. - -4.3 ---- - -* Adds functionality for allowing one to store the message body on-disk - instead of in the database. - -4.2 ---- - -* Adds 'envelope headers' to the Admin interface. - -4.1 ---- - -* Adds Django 1.7 migrations support. - -4.0 ---- - -* Adds ``html`` property returning the HTML contents of - ``django_mailbox.models.Message`` instances. - Thanks `@ariel17 `_! -* Adds translation support. - Thanks `@ariel17 `_! -* **Drops support for Python 3.2**. The fact that only versions of - Python newer than 3.2 allow unicode literals has convinced me - that supporting Python 3.2 is probably more trouble than it's worth. - Please let me know if you were using Python 3.2, and I've left you - out in the cold; I'm willing to fix Python 3.2 support if it is - actively used. - -3.4 ---- - -* Adds ``gmail`` transport allowing one to use Google - OAuth credentials for gathering messages from gmail. - Thanks `@alexlovelltroy `_! - -3.3 ---- - -* Adds functionality to ``imap`` transport allowing one to - archive processed e-mails. - Thanks `@yellowcap `_! - -3.2 ---- - -* Fixes `#13 `_; - Python 3 support had been broken for some time. Thanks for catching that, - `@greendee `_! - -3.1 ---- - -* Fixes a wide variety of unicode-related errors. - -3.0 ---- - -* Restructures message storage such that non-text message attachments - are stored as files, rather than in the database in their original - (probably base64-encoded) blobs. -* So many new tests. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1c02bea --- /dev/null +++ b/Makefile @@ -0,0 +1,51 @@ +VERSION := 0.1.0 + +clean: + -rm -rf dist + -rm -rf env + +patch: + git aftermerge patch || exit 1 + +minor: + git aftermerge minor || exit 1 + +major: + git aftermerge major || exit 1 + + +fmt: + poetry run black . || exit 1 + +lint: + poetry run flake8 . || exit 1 + +test: clean fmt lint + poetry run pytest || exit 1 + +build: test + poetry build + +deploytest: build + python3 -m venv env + ./env/bin/pip install wheel + ./env/bin/pip install dist/django-ngmailbox-\$(VERSION).tar.gz + -echo "source ./env/bin/activate" + +serve: + bash ./devenv/start_firefox.sh & + poetry run python manage.py runserver + +dev: + bash ./devenv/start_dev.sh & + poetry run python manage.py runserver + +migrations: + poetry run python manage.py makemigrations + poetry run python manage.py migrate + +# Not setup yet +#deploy: build +# poetry publish -r focus + + diff --git a/django_mailbox/transports/imap.py b/django_mailbox/transports/imap.py index 9df2b0e..a5bd616 100644 --- a/django_mailbox/transports/imap.py +++ b/django_mailbox/transports/imap.py @@ -36,6 +36,11 @@ class ImapTransport(EmailTransport): 'DJANGO_MAILBOX_DELETE_MESSAGE_FROM_SERVER', True ) + self.delete_message_store = getattr( + settings, + 'DJANGO_MAILBOX_DELETE_MESSAGE_STORE', + "/tmp/store.json" + ) self.hostname = hostname self.port = port self.archive = archive @@ -114,7 +119,29 @@ class ImapTransport(EmailTransport): # If the archive folder does not exist, create it self.server.create(self.archive) + # PoC of alternative method of storing email + if not self.delete_from_server: + j = {"uids":[]} + if os.path.exists("store.json"): + with open("store.json","r") as f: + j = json.load(f) + else: + with open("store.json","w") as f: + json.dump(j,f) + # PoC of alternative method of storing email + + for uid in message_ids: + # PoC of alternative method of storing email + if not self.delete_from_server: + if uid in j["uids"]: + continue + else: + j["uids"].append(uid) + with open("store.json","w") as f: + json.dump(j,f) + # PoC of alternative method of storing email + try: typ, msg_contents = self.server.uid('fetch', uid, '(RFC822)') if not msg_contents: diff --git a/pyproject.toml b/pyproject.toml index 3658f45..e3482f6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [tool.poetry] -name = "django-ngmailbox" +name = "django-mailbox2" version = "0.1.0" description = "I'm forking and making it my own." authors = ["Joe "] diff --git a/rtd_requirements.txt b/rtd_requirements.txt deleted file mode 100644 index 5e254ee..0000000 --- a/rtd_requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -django>=3.1.1,<3.2 -six diff --git a/test_requirements.txt b/test_requirements.txt deleted file mode 100644 index 3e5e40e..0000000 --- a/test_requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -pytest==2.9.1 -pytest-django==2.9.1 -mock==2.0.0 diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 6998106..0000000 --- a/tox.ini +++ /dev/null @@ -1,36 +0,0 @@ -[tox] -# sort by django version, next by python version -envlist= - flake8 - py{35,36}-django111 - py{35,36}-django20 - py{35,36,37}-django21 - py{35,36,37}-django22 - py{36,37,38}-django30 - -[testenv] -passenv=EMAIL_IMAP_SERVER EMAIL_ACCOUNT EMAIL_PASSWORD EMAIL_SMTP_SERVER -deps= - django111: django==1.11.* - django20: django==2.0.* - django21: django==2.0.* - django22: django==2.0.* - django30: django==3.0b1 - -r{toxinidir}/test_requirements.txt -sitepackages=False -commands= - python {toxinidir}/manage.py makemigrations --check --dry-run - python -Wd manage.py test -v2 {posargs} - -[testenv:docs] -deps= - sphinx - -r{toxinidir}/rtd_requirements.txt - . -commands=make html clean SPHINXOPTS="-W --keep-going" -changedir={toxinidir}/docs -allowlist_externals=make - -[testenv:flake8] -deps=flake8 -commands=flake8 django_mailbox