summaryrefslogtreecommitdiff
path: root/service/pixelated/adapter/mailstore
diff options
context:
space:
mode:
authorFolker Bernitt <fbernitt@thoughtworks.com>2015-07-28 14:27:01 +0200
committerFolker Bernitt <fbernitt@thoughtworks.com>2015-08-11 17:00:28 +0200
commitff739a697af362647c17a4010984439a03b673df (patch)
tree01878a43b6080a825e4dbb901fe9446be1cddd25 /service/pixelated/adapter/mailstore
parent37dc1b4d597b6c6d4801cfd41037763f82233ee0 (diff)
Added tests to get mails within a mailbox.
Diffstat (limited to 'service/pixelated/adapter/mailstore')
-rw-r--r--service/pixelated/adapter/mailstore/__init__.py4
-rw-r--r--service/pixelated/adapter/mailstore/leap_mailstore.py17
2 files changed, 19 insertions, 2 deletions
diff --git a/service/pixelated/adapter/mailstore/__init__.py b/service/pixelated/adapter/mailstore/__init__.py
index 47fd9869..6983194d 100644
--- a/service/pixelated/adapter/mailstore/__init__.py
+++ b/service/pixelated/adapter/mailstore/__init__.py
@@ -42,3 +42,7 @@ class MailStore(object):
def get_mailbox_mail_ids(self, mailbox_name):
pass
+
+
+def underscore_uuid(uuid):
+ return uuid.replace('-', '_')
diff --git a/service/pixelated/adapter/mailstore/leap_mailstore.py b/service/pixelated/adapter/mailstore/leap_mailstore.py
index 238fcf86..ee40e03b 100644
--- a/service/pixelated/adapter/mailstore/leap_mailstore.py
+++ b/service/pixelated/adapter/mailstore/leap_mailstore.py
@@ -15,7 +15,7 @@
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
from leap.mail.adaptors.soledad import SoledadMailAdaptor
from twisted.internet import defer
-from pixelated.adapter.mailstore import MailStore
+from pixelated.adapter.mailstore import MailStore, underscore_uuid
from leap.mail.mail import Message
from pixelated.adapter.model.mail import Mail
@@ -97,7 +97,7 @@ class LeapMailStore(MailStore):
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().set_mbox_uuid(mailbox.uuid)
yield message.get_wrapper().create(self.soledad)
# add behavious from insert_mdoc_id from mail.py
@@ -110,6 +110,15 @@ class LeapMailStore(MailStore):
yield message.get_wrapper().delete(self.soledad)
@defer.inlineCallbacks
+ def get_mailbox_mail_ids(self, mailbox_name):
+ mailbox = yield self._get_or_create_mailbox(mailbox_name)
+ fdocs = yield self.soledad.get_from_index('by-type-and-mbox-uuid', 'flags', underscore_uuid(mailbox.uuid))
+
+ mail_ids = map(lambda doc: _fdoc_id_to_mdoc_id(doc.doc_id), fdocs)
+
+ defer.returnValue(mail_ids)
+
+ @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
@@ -128,3 +137,7 @@ class LeapMailStore(MailStore):
def _is_empty_message(message):
return (message is None) or (message.get_wrapper().mdoc.doc_id is None)
+
+
+def _fdoc_id_to_mdoc_id(fdoc_id):
+ return 'M' + fdoc_id[1:]