diff options
Diffstat (limited to 'service/pixelated/adapter')
-rw-r--r-- | service/pixelated/adapter/mail_service.py | 3 | ||||
-rw-r--r-- | service/pixelated/adapter/pixelated_mail.py | 6 | ||||
-rw-r--r-- | service/pixelated/adapter/pixelated_mailbox.py | 8 | ||||
-rw-r--r-- | service/pixelated/adapter/pixelated_mailboxes.py | 7 | ||||
-rw-r--r-- | service/pixelated/adapter/soledad_querier.py | 1 |
5 files changed, 18 insertions, 7 deletions
diff --git a/service/pixelated/adapter/mail_service.py b/service/pixelated/adapter/mail_service.py index 0d3e00f7..c216e7ae 100644 --- a/service/pixelated/adapter/mail_service.py +++ b/service/pixelated/adapter/mail_service.py @@ -74,8 +74,7 @@ class MailService: raise NotImplementedError() def delete_mail(self, mail_id): - _mail = self.mailboxes.mail(mail_id) - return self.mailboxes.move_to_trash(_mail) + return self.mailboxes.move_to_trash(mail_id) def save_draft(self, draft): raise NotImplementedError() diff --git a/service/pixelated/adapter/pixelated_mail.py b/service/pixelated/adapter/pixelated_mail.py index b7323af9..3e0f1ee0 100644 --- a/service/pixelated/adapter/pixelated_mail.py +++ b/service/pixelated/adapter/pixelated_mail.py @@ -215,6 +215,12 @@ class PixelatedMail: def save(self): return self.querier.save_mail(self) + def set_mailbox(self, mailbox_name): + self.fdoc.content['mbox'] = mailbox_name + + def set_recent(self): + self.fdoc.content['flags'].append("\\Recent") + def set_from(self, _from): self.headers['From'] = [_from] diff --git a/service/pixelated/adapter/pixelated_mailbox.py b/service/pixelated/adapter/pixelated_mailbox.py index 85d965d1..62ea57e6 100644 --- a/service/pixelated/adapter/pixelated_mailbox.py +++ b/service/pixelated/adapter/pixelated_mailbox.py @@ -54,8 +54,16 @@ class PixelatedMailbox: def add(self, mail): self.querier.create_mail(mail, self.mailbox_name) + def add_existing(self, mail_ident): + mail = self.querier.mail(mail_ident) + mail.remove_all_tags() + mail.set_mailbox(self.mailbox_name) + mail.save() + self.add_mailbox_tag_if_not_there(mail) + def remove(self, ident): mail = self.querier.mail(ident) + mail.remove_all_tags() self.querier.remove_mail(mail) @classmethod diff --git a/service/pixelated/adapter/pixelated_mailboxes.py b/service/pixelated/adapter/pixelated_mailboxes.py index ff1aa421..aa39a5c4 100644 --- a/service/pixelated/adapter/pixelated_mailboxes.py +++ b/service/pixelated/adapter/pixelated_mailboxes.py @@ -60,11 +60,8 @@ class PixelatedMailBoxes(): self.drafts().remove(ident) return new_mail - def move_to_trash(self, mail): - origin_mailbox = mail.mailbox_name - - new_mail_id = self.trash().add(mail) - self._create_or_get(origin_mailbox).remove(mail) + def move_to_trash(self, mail_id): + new_mail_id = self.trash().add_existing(mail_id) return new_mail_id def mail(self, mail_id): diff --git a/service/pixelated/adapter/soledad_querier.py b/service/pixelated/adapter/soledad_querier.py index 7ce7f26d..61bada1a 100644 --- a/service/pixelated/adapter/soledad_querier.py +++ b/service/pixelated/adapter/soledad_querier.py @@ -57,6 +57,7 @@ class SoledadQuerier: # XXX update only what has to be updated self.soledad.put_doc(mail.fdoc) self.soledad.put_doc(mail.hdoc) + self._update_index([mail.fdoc, mail.hdoc]) def create_mail(self, mail, mailbox_name): uid = self._next_uid_for_mailbox(mailbox_name) |