diff options
author | Roberto Soares <roberto.tech@gmail.com> | 2015-04-07 21:52:41 -0300 |
---|---|---|
committer | Roberto Soares <roberto.tech@gmail.com> | 2015-04-09 15:59:38 -0300 |
commit | 49a7867a593c7e18288e44530935fa13fb6bee1e (patch) | |
tree | b21296c0b02402fee086c171348ba5e04320d1e1 /service/pixelated/adapter/services | |
parent | 2928dda9e0b21e05f1d22a6448733484e53fad40 (diff) |
Adds service to move mails to inbox
Diffstat (limited to 'service/pixelated/adapter/services')
-rw-r--r-- | service/pixelated/adapter/services/mail_service.py | 5 | ||||
-rw-r--r-- | service/pixelated/adapter/services/mailboxes.py | 8 |
2 files changed, 12 insertions, 1 deletions
diff --git a/service/pixelated/adapter/services/mail_service.py b/service/pixelated/adapter/services/mail_service.py index 03889f82..656bb4bc 100644 --- a/service/pixelated/adapter/services/mail_service.py +++ b/service/pixelated/adapter/services/mail_service.py @@ -97,6 +97,11 @@ class MailService(object): trashed_mail = self.mailboxes.move_to_trash(mail_id) self.search_engine.index_mail(trashed_mail) + def recover_mail(self, mail_id): + mail = self.mail(mail_id) + recovered_mail = self.mailboxes.move_to_inbox(mail_id) + self.search_engine.index_mail(recovered_mail) + def delete_permanent(self, mail_id): mail = self.mail(mail_id) self.search_engine.remove_from_index(mail_id) diff --git a/service/pixelated/adapter/services/mailboxes.py b/service/pixelated/adapter/services/mailboxes.py index a7a3a591..e9fe6ce5 100644 --- a/service/pixelated/adapter/services/mailboxes.py +++ b/service/pixelated/adapter/services/mailboxes.py @@ -49,8 +49,14 @@ class Mailboxes(object): return [self._create_or_get(leap_mailbox_name) for leap_mailbox_name in self.account.mailboxes] def move_to_trash(self, mail_id): + return self._move_to(mail_id, self.trash()) + + def move_to_inbox(self, mail_id): + return self._move_to(mail_id, self.inbox()) + + def _move_to(self, mail_id, mailbox): mail = self.querier.mail(mail_id) - mail.set_mailbox(self.trash().mailbox_name) + mail.set_mailbox(mailbox.mailbox_name) mail.save() return mail |