summaryrefslogtreecommitdiff
path: root/service/pixelated/adapter/soledad
diff options
context:
space:
mode:
authorFolker Bernitt <fbernitt@thoughtworks.com>2015-07-17 11:15:00 +0200
committerFolker Bernitt <fbernitt@thoughtworks.com>2015-08-11 17:00:24 +0200
commit953fa104ab56d38d65b21f9d2108a95f62a0e8b6 (patch)
tree8f2168b709b5ae54ec7aaff8cbac348d516d36f5 /service/pixelated/adapter/soledad
parent1ee61a27b1a11f6e60dfd34fb72d3c63f05e7e24 (diff)
Fixing integration tests.
Diffstat (limited to 'service/pixelated/adapter/soledad')
-rw-r--r--service/pixelated/adapter/soledad/soledad_facade_mixin.py10
-rw-r--r--service/pixelated/adapter/soledad/soledad_writer_mixin.py13
2 files changed, 16 insertions, 7 deletions
diff --git a/service/pixelated/adapter/soledad/soledad_facade_mixin.py b/service/pixelated/adapter/soledad/soledad_facade_mixin.py
index b58bb02f..e5dbb458 100644
--- a/service/pixelated/adapter/soledad/soledad_facade_mixin.py
+++ b/service/pixelated/adapter/soledad/soledad_facade_mixin.py
@@ -15,6 +15,7 @@
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
from twisted.internet import defer
+from leap.mail.mailbox_indexer import MailboxIndexer
class SoledadDbFacadeMixin(object):
@@ -72,10 +73,15 @@ class SoledadDbFacadeMixin(object):
def get_mbox(self, mbox):
return self.soledad.get_from_index('by-type-and-mbox', 'mbox', mbox) if mbox else []
+ @defer.inlineCallbacks
def get_lastuid(self, mbox):
if isinstance(mbox, str):
- mbox = self.get_mbox(mbox)[0]
- return mbox.content['lastuid']
+ mbox = (yield defer.maybeDeferred(self.get_mbox(mbox)))[0]
+
+ indexer = MailboxIndexer(self.soledad)
+ last_uuid = yield indexer.get_last_uid(mbox.content['uuid'])
+
+ defer.returnValue(last_uuid)
def get_search_index_masterkey(self):
return self.soledad.get_from_index('by-type', 'index_key')
diff --git a/service/pixelated/adapter/soledad/soledad_writer_mixin.py b/service/pixelated/adapter/soledad/soledad_writer_mixin.py
index ed18c0d0..262351cb 100644
--- a/service/pixelated/adapter/soledad/soledad_writer_mixin.py
+++ b/service/pixelated/adapter/soledad/soledad_writer_mixin.py
@@ -33,15 +33,18 @@ class SoledadWriterMixin(SoledadDbFacadeMixin, object):
def save_mail(self, mail):
self.put_doc(mail.fdoc)
+ @defer.inlineCallbacks
def create_mail(self, mail, mailbox_name):
- mbox_doc = self.get_mbox(mailbox_name)[0]
- uid = self.get_lastuid(mbox_doc)
+ mbox_doc = (yield self.get_mbox(mailbox_name))[0]
+ uid = 1 + (yield self.get_lastuid(mbox_doc))
+
self.create_docs(mail.get_for_save(next_uid=uid, mailbox=mailbox_name))
- mbox_doc.content['lastuid'] = uid + 1
- self.put_doc(mbox_doc)
+ # FIXME need to update meta message (mdoc)
+ # mbox_doc.content['lastuid'] = uid + 1
+ # self.put_doc(mbox_doc)
- return self.mail(mail.ident)
+ defer.returnValue((yield self.mail(mail.ident)))
def remove_mail(self, mail):
# FIX-ME: Must go through all the part_map phash to delete all the cdocs