diff options
author | Patrick Maia and Victor Shyba <pixelated-team+pmaia+vshyba@thoughtworks.com> | 2014-09-08 08:26:52 +0000 |
---|---|---|
committer | Patrick Maia <pmaia@thoughtworks.com> | 2014-09-08 08:29:54 +0000 |
commit | 10112b7d862f5d2d24b6c295e08c4ebd73d54ee2 (patch) | |
tree | a5f820ee555941ac9c0a921d7e6e33296f0b111d /service/pixelated/adapter | |
parent | 4d654c66af16d0b737669865758faf24b9e77378 (diff) |
\#72 - adds tag with the name of the mailbox on all mails that does not have it during mails fetch
Diffstat (limited to 'service/pixelated/adapter')
-rw-r--r-- | service/pixelated/adapter/pixelated_mailbox.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/service/pixelated/adapter/pixelated_mailbox.py b/service/pixelated/adapter/pixelated_mailbox.py index 2723dfc1..1a17926a 100644 --- a/service/pixelated/adapter/pixelated_mailbox.py +++ b/service/pixelated/adapter/pixelated_mailbox.py @@ -40,8 +40,16 @@ class PixelatedMailbox: def mails(self): mails = self.leap_mailbox.messages or [] - mails = [PixelatedMail.from_leap_mail(mail) for mail in mails] - return mails + result = [] + mailbox_name = self.leap_mailbox.mbox + for mail in mails: + pixelated_mail = PixelatedMail.from_leap_mail(mail) + if not pixelated_mail.has_tag(mailbox_name): + new_tags = set([mailbox_name.lower()]) + pixelated_mail.update_tags(new_tags.union(pixelated_mail.tags)) + self.notify_tags_updated(new_tags, [], pixelated_mail.ident) + result.append(pixelated_mail) + return result def mails_by_tags(self, tags): if 'all' in tags: |