summaryrefslogtreecommitdiff
path: root/service/pixelated/adapter/mailstore
diff options
context:
space:
mode:
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)