From 97a5e93f5b569556a6eb8b257647a0a757b328b8 Mon Sep 17 00:00:00 2001 From: Patrick Maia Date: Wed, 1 Oct 2014 12:21:59 -0300 Subject: #53 - does not automatically add mailbox tag --- service/pixelated/adapter/pixelated_mailbox.py | 10 +--------- service/pixelated/adapter/tag_service.py | 4 ++-- 2 files changed, 3 insertions(+), 11 deletions(-) (limited to 'service/pixelated/adapter') diff --git a/service/pixelated/adapter/pixelated_mailbox.py b/service/pixelated/adapter/pixelated_mailbox.py index 62ea57e6..e8c063e8 100644 --- a/service/pixelated/adapter/pixelated_mailbox.py +++ b/service/pixelated/adapter/pixelated_mailbox.py @@ -26,23 +26,16 @@ class PixelatedMailbox: self.mailbox_tag = mailbox_name.lower() self.querier = querier - def add_mailbox_tag_if_not_there(self, pixelated_mail): - if not pixelated_mail.has_tag(self.mailbox_tag): - pixelated_mail.update_tags({self.mailbox_tag}.union(pixelated_mail.tags)) - self.tag_service.notify_tags_updated({self.mailbox_tag}, [], pixelated_mail.ident) - pixelated_mail.mark_as_not_recent() - def mails(self): _mails = self.querier.all_mails_by_mailbox(self.mailbox_name) result = [] for mail in _mails: - self.add_mailbox_tag_if_not_there(mail) result.append(mail) return result def mails_by_tags(self, tags): - if 'all' in tags: + if 'all' in tags or self.mailbox_tag in tags: return self.mails() return [mail for mail in self.mails() if len(mail.tags.intersection(tags)) > 0] @@ -59,7 +52,6 @@ class PixelatedMailbox: 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) diff --git a/service/pixelated/adapter/tag_service.py b/service/pixelated/adapter/tag_service.py index ecc64fad..dc13bc54 100644 --- a/service/pixelated/adapter/tag_service.py +++ b/service/pixelated/adapter/tag_service.py @@ -20,11 +20,11 @@ from pixelated.adapter.tag_index import TagIndex class TagService: instance = None - SPECIAL_TAGS = [Tag('inbox', True), Tag('sent', True), Tag('drafts', True), Tag('trash', True)] + SPECIAL_TAGS = {Tag('inbox', True), Tag('sent', True), Tag('drafts', True), Tag('trash', True)} @classmethod def extract_reserved(cls, tags): - return set(tag.name for tag in cls.SPECIAL_TAGS if tag.name in tags) + return {tag.name for tag in cls.SPECIAL_TAGS if tag.name in tags} @classmethod def get_instance(cls): -- cgit v1.2.3