summaryrefslogtreecommitdiff
path: root/service/app/adapter/mail_service.py
diff options
context:
space:
mode:
authorBruno Wagner Goncalves and Patrick Maia <pixelated-team+bwagner+pmaia@thoughtworks.com>2014-08-14 12:11:48 -0300
committerPatrick Maia <patrickjourdanmaia@gmail.com>2014-08-14 12:11:48 -0300
commit5b2538cd3cd5cb012021b7043a2ef427b7ace89a (patch)
tree027387ad96f09ce96a03e12abaa66731009c2250 /service/app/adapter/mail_service.py
parent998f8d33fcef28c90365cd58f0820683e518e398 (diff)
Update mail with new tags should be working now
Diffstat (limited to 'service/app/adapter/mail_service.py')
-rw-r--r--service/app/adapter/mail_service.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/service/app/adapter/mail_service.py b/service/app/adapter/mail_service.py
index b5ae09f2..fb5b52c3 100644
--- a/service/app/adapter/mail_service.py
+++ b/service/app/adapter/mail_service.py
@@ -54,6 +54,23 @@ class MailService:
def mails(self, query):
return self.mailbox.messages or []
+ def update_mail(self, dict_mail):
+ # Iterating over messages because messages.getUID() is not trustworthy
+ mail = None
+ for message in self.mailbox.messages:
+ if message.getUID() == dict_mail['ident']:
+ mail = PixelatedMail(message)
+
+ new_tags = mail.update_tags(dict_mail['tags'])
+
+ self._update_tag_list(new_tags)
+
+ return mail
+
+ def _update_tag_list(self, tags):
+ for tag in tags:
+ self.tags.add(tag)
+
def _switch_mailbox(self, name):
mailbox = None
if name in self.SPECIAL_BOXES: