diff options
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 |