summaryrefslogtreecommitdiff
path: root/service/pixelated/adapter/mailstore/leap_mailstore.py
diff options
context:
space:
mode:
authorFolker Bernitt <fbernitt@thoughtworks.com>2015-07-27 17:27:24 +0200
committerFolker Bernitt <fbernitt@thoughtworks.com>2015-08-11 17:00:28 +0200
commit6d72d76f7753004c84d1a0eed6667b551c11b626 (patch)
treec66c8973389cd4b00a5356b87c5024e49aa7d30f /service/pixelated/adapter/mailstore/leap_mailstore.py
parentbf96b1077bdd777400a40fc2fe3acc83552d70de (diff)
Added add mailbox and add message behaviour.
- Add message does not yet mail index
Diffstat (limited to 'service/pixelated/adapter/mailstore/leap_mailstore.py')
-rw-r--r--service/pixelated/adapter/mailstore/leap_mailstore.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/service/pixelated/adapter/mailstore/leap_mailstore.py b/service/pixelated/adapter/mailstore/leap_mailstore.py
index 1b72707f..9b6e0e0d 100644
--- a/service/pixelated/adapter/mailstore/leap_mailstore.py
+++ b/service/pixelated/adapter/mailstore/leap_mailstore.py
@@ -86,6 +86,21 @@ class LeapMailStore(MailStore):
defer.returnValue(mails)
@defer.inlineCallbacks
+ def add_mailbox(self, mailbox_name):
+ mailbox = yield self._get_or_create_mailbox(mailbox_name)
+ defer.returnValue(mailbox)
+
+ @defer.inlineCallbacks
+ def add_mail(self, mailbox_name, raw_msg):
+ mailbox = yield self._get_or_create_mailbox(mailbox_name)
+ message = SoledadMailAdaptor().get_msg_from_string(Message, raw_msg)
+ message.get_wrapper().set_mbox_uuid(mailbox.doc_id)
+ message.get_wrapper().create(self.soledad)
+
+ # add behavious from insert_mdoc_id from mail.py
+ defer.returnValue(mailbox)
+
+ @defer.inlineCallbacks
def _leap_message_to_leap_mail(self, mail_id, message, include_body):
if include_body:
body = (yield message._wrapper.get_body(self.soledad)).raw
@@ -95,5 +110,8 @@ class LeapMailStore(MailStore):
defer.returnValue(mail)
+ def _get_or_create_mailbox(self, mailbox_name):
+ return SoledadMailAdaptor().get_or_create_mbox(self.soledad, mailbox_name)
+
def _fetch_msg_from_soledad(self, mail_id):
return SoledadMailAdaptor().get_msg_from_mdoc_id(Message, self.soledad, mail_id)