diff options
author | Patrick Maia <patrickjourdanmaia@gmail.com> | 2014-10-01 12:21:59 -0300 |
---|---|---|
committer | Patrick Maia <patrickjourdanmaia@gmail.com> | 2014-10-01 16:43:43 -0300 |
commit | 97a5e93f5b569556a6eb8b257647a0a757b328b8 (patch) | |
tree | fd7be049a3868a0db36de7705aba355a2aa708be /service/pixelated | |
parent | 6244ef377aace0659c088f6c95878ec8aeb0cd02 (diff) |
#53 - does not automatically add mailbox tag
Diffstat (limited to 'service/pixelated')
-rw-r--r-- | service/pixelated/adapter/pixelated_mailbox.py | 10 | ||||
-rw-r--r-- | service/pixelated/adapter/tag_service.py | 4 |
2 files changed, 3 insertions, 11 deletions
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): |