summaryrefslogtreecommitdiff
path: root/service/pixelated/adapter
diff options
context:
space:
mode:
authorFolker Bernitt <fbernitt@thoughtworks.com>2015-07-28 10:49:52 +0200
committerFolker Bernitt <fbernitt@thoughtworks.com>2015-08-11 17:00:28 +0200
commit37dc1b4d597b6c6d4801cfd41037763f82233ee0 (patch)
treebea7b574dd40c441422558444e1450c983473376 /service/pixelated/adapter
parent6450be6dd2eb2d5a683f81657ed197c930fd9784 (diff)
Added delete mail to mail store.
- Fix for empty mails returned by leap_mail.
Diffstat (limited to 'service/pixelated/adapter')
-rw-r--r--service/pixelated/adapter/mailstore/leap_mailstore.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/service/pixelated/adapter/mailstore/leap_mailstore.py b/service/pixelated/adapter/mailstore/leap_mailstore.py
index 3c6544df..238fcf86 100644
--- a/service/pixelated/adapter/mailstore/leap_mailstore.py
+++ b/service/pixelated/adapter/mailstore/leap_mailstore.py
@@ -56,7 +56,10 @@ class LeapMailStore(MailStore):
def get_mail(self, mail_id, include_body=False):
try:
message = yield self._fetch_msg_from_soledad(mail_id)
- leap_mail = yield self._leap_message_to_leap_mail(mail_id, message, include_body)
+ if not _is_empty_message(message):
+ leap_mail = yield self._leap_message_to_leap_mail(mail_id, message, include_body)
+ else:
+ leap_mail = None
defer.returnValue(leap_mail)
except AttributeError, e:
@@ -98,7 +101,13 @@ class LeapMailStore(MailStore):
yield message.get_wrapper().create(self.soledad)
# add behavious from insert_mdoc_id from mail.py
- defer.returnValue(message)
+ mail = yield self._leap_message_to_leap_mail(message.get_wrapper().mdoc.doc_id, message, include_body=False)
+ defer.returnValue(mail)
+
+ @defer.inlineCallbacks
+ def delete_mail(self, mail_id):
+ message = yield self._fetch_msg_from_soledad(mail_id)
+ yield message.get_wrapper().delete(self.soledad)
@defer.inlineCallbacks
def _leap_message_to_leap_mail(self, mail_id, message, include_body):
@@ -115,3 +124,7 @@ class LeapMailStore(MailStore):
def _fetch_msg_from_soledad(self, mail_id):
return SoledadMailAdaptor().get_msg_from_mdoc_id(Message, self.soledad, mail_id)
+
+
+def _is_empty_message(message):
+ return (message is None) or (message.get_wrapper().mdoc.doc_id is None)