diff options
Diffstat (limited to 'service/pixelated')
-rw-r--r-- | service/pixelated/adapter/mail_service.py | 4 | ||||
-rw-r--r-- | service/pixelated/adapter/search.py | 3 | ||||
-rw-r--r-- | service/pixelated/adapter/soledad_querier.py | 4 | ||||
-rw-r--r-- | service/pixelated/controllers/mails_controller.py | 8 |
4 files changed, 14 insertions, 5 deletions
diff --git a/service/pixelated/adapter/mail_service.py b/service/pixelated/adapter/mail_service.py index cc03ab3a..6c093b6d 100644 --- a/service/pixelated/adapter/mail_service.py +++ b/service/pixelated/adapter/mail_service.py @@ -68,6 +68,10 @@ class MailService: def delete_mail(self, mail_id): return self.mailboxes.move_to_trash(mail_id) + def delete_permanent(self, mail_id): + mail = self.mail(mail_id) + self.querier.remove_mail(mail) + def save_draft(self, draft): raise NotImplementedError() diff --git a/service/pixelated/adapter/search.py b/service/pixelated/adapter/search.py index 71b72dba..559e8a99 100644 --- a/service/pixelated/adapter/search.py +++ b/service/pixelated/adapter/search.py @@ -99,7 +99,8 @@ class SearchEngine(object): body=TEXT(stored=False), tag=KEYWORD(stored=True, commas=True), flags=KEYWORD(stored=True, commas=True), - raw=TEXT(stored=False)) + raw=TEXT(stored=False), + deleted=BOOLEAN(stored=False)) def _create_index(self): return whoosh.index.create_in(self.INDEX_FOLDER, self._mail_schema(), indexname='mails') diff --git a/service/pixelated/adapter/soledad_querier.py b/service/pixelated/adapter/soledad_querier.py index 318e1539..42af6d2b 100644 --- a/service/pixelated/adapter/soledad_querier.py +++ b/service/pixelated/adapter/soledad_querier.py @@ -67,9 +67,9 @@ class SoledadQuerier: def remove_mail(self, mail): _mail = self.mail(mail.ident) # FIX-ME: Must go through all the part_map phash to delete all the cdocs - self.soledad.delete_doc(_mail.bdoc) - self.soledad.delete_doc(_mail.hdoc) self.soledad.delete_doc(_mail.fdoc) + self.soledad.delete_doc(_mail.hdoc) + self.soledad.delete_doc(_mail.bdoc) def idents_by_mailbox(self, mailbox_name): return set(doc.content['chash'] for doc in self.soledad.get_from_index('by-type-and-mbox-and-deleted', 'flags', mailbox_name, '0')) diff --git a/service/pixelated/controllers/mails_controller.py b/service/pixelated/controllers/mails_controller.py index b039495f..e85d338d 100644 --- a/service/pixelated/controllers/mails_controller.py +++ b/service/pixelated/controllers/mails_controller.py @@ -70,8 +70,12 @@ class MailsController: return "" def delete_mail(self, mail_id): - trashed_mail = self._mail_service.delete_mail(mail_id) - self._search_engine.index_mail(trashed_mail) + mail = self._mail_service.mail(mail_id) + if mail.mailbox_name == 'TRASH': + self._mail_service.delete_permanent(mail_id) + else: + trashed_mail = self._mail_service.delete_mail(mail_id) + self._search_engine.index_mail(trashed_mail) return respond_json(None) def delete_mails(self): |