diff options
author | Alexandre Pretto Nunes <anunes@thoughtworks.com> | 2014-09-04 19:28:39 -0300 |
---|---|---|
committer | Alexandre Pretto Nunes <anunes@thoughtworks.com> | 2014-09-04 19:29:48 -0300 |
commit | aa40c93c625baecbef79168c2cffd683be1ff8f3 (patch) | |
tree | 9eab0a47534c932cd30bf3b2c0bd54f61e985511 /service/pixelated/adapter | |
parent | 8f38ab0b6e859358a9d6ddf92467a6dfd7b9fad9 (diff) |
Implement mark_as_read for emails
Diffstat (limited to 'service/pixelated/adapter')
-rw-r--r-- | service/pixelated/adapter/mail_service.py | 2 | ||||
-rw-r--r-- | service/pixelated/adapter/pixelated_mail.py | 14 |
2 files changed, 10 insertions, 6 deletions
diff --git a/service/pixelated/adapter/mail_service.py b/service/pixelated/adapter/mail_service.py index 3cbbe90e..e3444b9f 100644 --- a/service/pixelated/adapter/mail_service.py +++ b/service/pixelated/adapter/mail_service.py @@ -62,7 +62,7 @@ class MailService: raise NotImplementedError() def mark_as_read(self, mail_id): - raise NotImplementedError() + return self.mail(mail_id).mark_as_read() def tags_for_thread(self, thread): raise NotImplementedError() diff --git a/service/pixelated/adapter/pixelated_mail.py b/service/pixelated/adapter/pixelated_mail.py index cf0e12a5..8ed27262 100644 --- a/service/pixelated/adapter/pixelated_mail.py +++ b/service/pixelated/adapter/pixelated_mail.py @@ -33,7 +33,7 @@ class PixelatedMail: mail.headers = mail._extract_headers() mail.date = PixelatedMail._get_date(mail.headers) mail.ident = leap_mail.getUID() - mail.status = mail._extract_status() + mail.status = set(mail._extract_status()) mail.security_casing = {} mail.tags = mail._extract_tags() return mail @@ -75,6 +75,9 @@ class PixelatedMail: self._persist_mail_tags(tags) return self.tags + def mark_as_read(self): + self.status.add("read") + def _persist_mail_tags(self, current_tags): tags_headers = [tag.name for tag in current_tags] hdoc = self.leap_mail.hdoc @@ -126,8 +129,9 @@ class PixelatedMail: def from_dict(mail_dict): mail = PixelatedMail() - mail.headers = mail_dict['header'] - mail.body = mail_dict['body'] - mail.ident = mail_dict['ident'] - mail.tags = mail_dict['tags'] + mail.headers = mail_dict.get('header', {}) + mail.body = mail_dict.get('body', '') + mail.ident = mail_dict.get('ident', None) + mail.tags = mail_dict.get('tags', []) + mail.status = set(mail_dict.get('status', [])) return mail |