mirror of
https://github.com/coddingtonbear/django-mailbox.git
synced 2026-07-10 06:48:19 +02:00
adds unique constrain to the message id and a bit of a change on how to create a message
This commit is contained in:
parent
1f018e9bdc
commit
83ee3bc4be
4 changed files with 33 additions and 29 deletions
|
|
@ -36,9 +36,6 @@ class ImapTransport(EmailTransport):
|
|||
self.delete_message_from_server = getattr(
|
||||
settings, "DJANGO_MAILBOX_DELETE_MESSAGE_FROM_SERVER", True
|
||||
)
|
||||
self.delete_message_store = getattr(
|
||||
settings, "DJANGO_MAILBOX_DELETE_MESSAGE_ID_STORE", "/tmp/store.json"
|
||||
)
|
||||
self.hostname = hostname
|
||||
self.port = port
|
||||
self.archive = archive
|
||||
|
|
@ -111,28 +108,8 @@ 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_message_from_server:
|
||||
j = {"uids": []}
|
||||
if 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_message_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