mirror of
https://github.com/coddingtonbear/django-mailbox.git
synced 2026-07-10 06:48:19 +02:00
changes repo to customized solution
This commit is contained in:
parent
0de5779dd7
commit
85870c896f
8 changed files with 93 additions and 135 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue