Skip to content

Commit

Permalink
Implement email deletion in webapp (#291)
Browse files Browse the repository at this point in the history
  • Loading branch information
c-w authored Jan 22, 2020
1 parent cac05ed commit f5e3c10
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion opwen_email_server/integration/webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from opwen_email_server.services.storage import AzureObjectStorage
from opwen_email_server.utils.collections import chunks
from opwen_email_server.utils.email_parser import get_domain
from opwen_email_server.utils.email_parser import get_recipients


class AzureRole:
Expand Down Expand Up @@ -212,7 +213,20 @@ def num_pending(self) -> int:
return 0

def _delete(self, email_address: str, uids: Iterable[str]):
pass
for uid in uids:
email = self.get(uid)
if not email:
continue

if email_address == email.get('from'):
folder = mailbox.SENT_FOLDER
elif email_address in get_recipients(email):
folder = mailbox.RECEIVED_FOLDER
else:
continue

self._mailbox_storage.delete(f"{email_address}/{folder}/{email['sent_at']}/{uid}")
self._email_storage.delete(uid)

def _mark_sent(self, uids: Iterable[str]):
pass
Expand Down

0 comments on commit f5e3c10

Please sign in to comment.