diff options
author | Victor Shyba <victor.shyba@gmail.com> | 2015-08-25 18:36:51 -0300 |
---|---|---|
committer | Victor Shyba <victor.shyba@gmail.com> | 2015-08-25 18:36:51 -0300 |
commit | 7c385309dfe9fcfbbad012d46f44e0b19aee82b1 (patch) | |
tree | 90c49779e8871a182c79edcf6a4b9361ac13a85a /service/pixelated/adapter | |
parent | 552a0471a2223f4d48e1a81ad9a51385deafc0ca (diff) |
[refactor] remove mailbox references
Extracted listener logic and removed remaining mailboxes references
Issues
-- #439
-- #440
Diffstat (limited to 'service/pixelated/adapter')
-rw-r--r-- | service/pixelated/adapter/listeners/mailbox_indexer_listener.py | 8 | ||||
-rw-r--r-- | service/pixelated/adapter/services/mail_service.py | 7 |
2 files changed, 11 insertions, 4 deletions
diff --git a/service/pixelated/adapter/listeners/mailbox_indexer_listener.py b/service/pixelated/adapter/listeners/mailbox_indexer_listener.py index ce056a3c..8e7eca1a 100644 --- a/service/pixelated/adapter/listeners/mailbox_indexer_listener.py +++ b/service/pixelated/adapter/listeners/mailbox_indexer_listener.py @@ -52,3 +52,11 @@ class MailboxIndexerListener(object): def __repr__(self): return 'MailboxListener: ' + self.mailbox_name + + +@defer.inlineCallbacks +def listen_all_mailboxes(account, search_engine, mail_store): + MailboxIndexerListener.SEARCH_ENGINE = search_engine + mailboxes = yield account.account.list_all_mailbox_names() + for mailbox_name in mailboxes: + yield MailboxIndexerListener.listen(account, mailbox_name, mail_store) diff --git a/service/pixelated/adapter/services/mail_service.py b/service/pixelated/adapter/services/mail_service.py index 4623a5eb..d47bdd87 100644 --- a/service/pixelated/adapter/services/mail_service.py +++ b/service/pixelated/adapter/services/mail_service.py @@ -21,8 +21,7 @@ from pixelated.adapter.services.tag_service import extract_reserved_tags class MailService(object): - def __init__(self, mailboxes, mail_sender, mail_store, soledad_querier, search_engine): - self.mailboxes = mailboxes + def __init__(self, mail_sender, mail_store, soledad_querier, search_engine): self.mail_store = mail_store self.querier = soledad_querier self.search_engine = search_engine @@ -122,9 +121,9 @@ class MailService(object): else: yield self.mail_store.move_mail_to_mailbox(mail_id, 'TRASH') + @defer.inlineCallbacks def recover_mail(self, mail_id): - recovered_mail = self.mailboxes.move_to_inbox(mail_id) - self.search_engine.index_mail(recovered_mail) + yield self.mail_store.move_mail_to_mailbox(mail_id, 'INBOX') @defer.inlineCallbacks def delete_permanent(self, mail_id): |