summaryrefslogtreecommitdiff
path: root/service/pixelated/adapter/mailstore
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
parentbf96b1077bdd777400a40fc2fe3acc83552d70de (diff)
Added add mailbox and add message behaviour.
- Add message does not yet mail index
Diffstat (limited to 'service/pixelated/adapter/mailstore')
-rw-r--r--service/pixelated/adapter/mailstore/__init__.py3
-rw-r--r--service/pixelated/adapter/mailstore/leap_mailstore.py18
2 files changed, 21 insertions, 0 deletions
diff --git a/service/pixelated/adapter/mailstore/__init__.py b/service/pixelated/adapter/mailstore/__init__.py
index 05d21e8b..47fd9869 100644
--- a/service/pixelated/adapter/mailstore/__init__.py
+++ b/service/pixelated/adapter/mailstore/__init__.py
@@ -37,5 +37,8 @@ class MailStore(object):
def get_mailbox_names(self):
pass
+ def add_mailbox(self, mailbox_name):
+ pass
+
def get_mailbox_mail_ids(self, mailbox_name):
pass
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)