diff options
author | Folker Bernitt <fbernitt@thoughtworks.com> | 2015-07-14 20:48:15 +0200 |
---|---|---|
committer | Folker Bernitt <fbernitt@thoughtworks.com> | 2015-08-11 17:00:22 +0200 |
commit | b8f21dfee9f541f1a996626f1ed78e0545b1016e (patch) | |
tree | b72221e04e9fc52ad8a666eb61102fdb49211def /service | |
parent | 9d72f648d571c8bf025295c5ba7835d69c0b587f (diff) |
Moved mark_all_as_not_recent to yield.
Diffstat (limited to 'service')
5 files changed, 11 insertions, 6 deletions
diff --git a/service/pixelated/adapter/model/mail.py b/service/pixelated/adapter/model/mail.py index 084b41ed..fd08af07 100644 --- a/service/pixelated/adapter/model/mail.py +++ b/service/pixelated/adapter/model/mail.py @@ -383,7 +383,8 @@ class PixelatedMail(Mail): @property def mailbox_name(self): - return self.fdoc.content.get('mbox') + # FIXME mbox is no longer available, instead we now have mbox_uuid + return self.fdoc.content.get('mbox_uuid') @property def is_recent(self): diff --git a/service/pixelated/adapter/soledad/soledad_facade_mixin.py b/service/pixelated/adapter/soledad/soledad_facade_mixin.py index 99a17df8..f4198b5c 100644 --- a/service/pixelated/adapter/soledad/soledad_facade_mixin.py +++ b/service/pixelated/adapter/soledad/soledad_facade_mixin.py @@ -44,8 +44,10 @@ class SoledadDbFacadeMixin(object): if len(header): defer.returnValue(header[0]) + @defer.inlineCallbacks def get_recent_by_mbox(self, mbox): - return self.soledad.get_from_index('by-type-and-mbox', 'rct', mbox) if mbox else [] + defer.returnValue( + (yield self.soledad.get_from_index('by-type-and-mbox', 'rct', mbox) if mbox else [])) def put_doc(self, doc): return self.soledad.put_doc(doc) diff --git a/service/pixelated/adapter/soledad/soledad_reader_mixin.py b/service/pixelated/adapter/soledad/soledad_reader_mixin.py index dcc95bd4..fc673726 100644 --- a/service/pixelated/adapter/soledad/soledad_reader_mixin.py +++ b/service/pixelated/adapter/soledad/soledad_reader_mixin.py @@ -50,7 +50,7 @@ class SoledadReaderMixin(SoledadDbFacadeMixin, object): fdocs_hdocs_bodyphash = [(f[0], f[1], f[1].content.get('body')) for f in fdocs_hdocs] fdocs_hdocs_bdocs_parts = [] for fdoc, hdoc, body_phash in fdocs_hdocs_bodyphash: - bdoc = self.get_content_by_phash(body_phash) + bdoc = yield self.get_content_by_phash(body_phash) if not bdoc: continue parts = yield self._extract_parts(hdoc.content) diff --git a/service/pixelated/adapter/soledad/soledad_writer_mixin.py b/service/pixelated/adapter/soledad/soledad_writer_mixin.py index b0d21b93..3e732d9b 100644 --- a/service/pixelated/adapter/soledad/soledad_writer_mixin.py +++ b/service/pixelated/adapter/soledad/soledad_writer_mixin.py @@ -15,12 +15,14 @@ # along with Pixelated. If not, see <http://www.gnu.org/licenses/>. from pixelated.adapter.soledad.soledad_facade_mixin import SoledadDbFacadeMixin +from twisted.internet import defer class SoledadWriterMixin(SoledadDbFacadeMixin, object): + @defer.inlineCallbacks def mark_all_as_not_recent(self): for mailbox in ['INBOX', 'DRAFTS', 'SENT', 'TRASH']: - rct = self.get_recent_by_mbox(mailbox) + rct = yield self.get_recent_by_mbox(mailbox) if not rct or not rct[0].content['rct']: return rct = rct[0] diff --git a/service/pixelated/config/services.py b/service/pixelated/config/services.py index 7b5b1f1d..a1c7ac1b 100644 --- a/service/pixelated/config/services.py +++ b/service/pixelated/config/services.py @@ -45,8 +45,8 @@ class Services(object): @defer.inlineCallbacks def post_setup(self, soledad_querier, leap_session): self.search_engine.index_mails( - mails=(yield self.mail_service.all_mails()), - callback=soledad_querier.mark_all_as_not_recent) + mails=(yield self.mail_service.all_mails())) + yield soledad_querier.mark_all_as_not_recent() soledad_querier.remove_duplicates() InputMail.FROM_EMAIL_ADDRESS = leap_session.account_email() |