diff options
Diffstat (limited to 'service')
-rw-r--r-- | service/pixelated/adapter/pixelated_mail.py | 12 | ||||
-rw-r--r-- | service/pixelated/adapter/pixelated_mailbox.py | 4 | ||||
-rw-r--r-- | service/test/adapter/pixelated_mail_test.py | 2 |
3 files changed, 12 insertions, 6 deletions
diff --git a/service/pixelated/adapter/pixelated_mail.py b/service/pixelated/adapter/pixelated_mail.py index 6d5a9335..29dbdaa3 100644 --- a/service/pixelated/adapter/pixelated_mail.py +++ b/service/pixelated/adapter/pixelated_mail.py @@ -33,6 +33,7 @@ class PixelatedMail: self.tags = [] self.mailbox_name = None self.uid = None + self._ident = None @staticmethod def from_leap_mail(leap_mail, tag_service=TagService.get_instance()): @@ -40,7 +41,7 @@ class PixelatedMail: mail.tag_service = tag_service mail.leap_mail = leap_mail mail.mailbox_name = leap_mail._mbox - mail.ident = gen_pixelated_uid(leap_mail._mbox, leap_mail.getUID()) + mail.uid = leap_mail.getUID() mail.body = leap_mail.bdoc.content['raw'] mail.headers = mail._extract_headers() mail.headers['date'] = PixelatedMail._get_date(mail.headers) @@ -53,6 +54,13 @@ class PixelatedMail: def is_recent(self): return Status('recent') in self.status + @property + def ident(self): + if self.uid and self.mailbox_name: + return gen_pixelated_uid(self.mailbox_name, self.uid) + if self._ident: + return self._ident + def set_from(self, _from): self.headers['from'] = [_from] @@ -172,7 +180,7 @@ def from_dict(mail_dict): mail.headers = mail_dict.get('header', {}) mail.headers['date'] = pixelated.support.date.iso_now() mail.body = mail_dict.get('body', '') - mail.ident = mail_dict.get('ident', None) + mail._ident = mail_dict.get('ident', None) mail.tags = set(mail_dict.get('tags', [])) mail.status = set(mail_dict.get('status', [])) return mail diff --git a/service/pixelated/adapter/pixelated_mailbox.py b/service/pixelated/adapter/pixelated_mailbox.py index d6bd924b..fc28c733 100644 --- a/service/pixelated/adapter/pixelated_mailbox.py +++ b/service/pixelated/adapter/pixelated_mailbox.py @@ -63,9 +63,7 @@ class PixelatedMailbox: return message def add(self, mail, use_smtp_format=False): - leap_id = self._do_add_async(mail, use_smtp_format) - new_id = gen_pixelated_uid(self.leap_mailbox.mbox, leap_id) - return new_id + return self._do_add_async(mail, use_smtp_format) @wait_for(timeout=3.0) def _do_add_async(self, mail, use_smtp_format): diff --git a/service/test/adapter/pixelated_mail_test.py b/service/test/adapter/pixelated_mail_test.py index 7199fc55..c9f5e67d 100644 --- a/service/test/adapter/pixelated_mail_test.py +++ b/service/test/adapter/pixelated_mail_test.py @@ -66,7 +66,7 @@ class TestPixelatedMail(unittest.TestCase): self.assertEqual(mail.headers['to'], ['to@pixelated.org', 'anotherto@pixelated.org']) self.assertEqual(mail.headers['bcc'], ['bcc@pixelated.org', 'anotherbcc@pixelated.org']) self.assertEqual(mail.headers['subject'], 'Oi') - self.assertEqual(mail.ident, '') + self.assertEqual(mail.ident, None) self.assertEqual(mail.tags, set(['sent'])) self.assertEqual(mail.body, 'Este \xe9 o corpo') |