summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorNeissi Torres Lima <neissi.lima@gmail.com>2014-09-04 19:25:03 -0300
committerNeissi Torres Lima <neissi.lima@gmail.com>2014-09-04 19:25:22 -0300
commit8f38ab0b6e859358a9d6ddf92467a6dfd7b9fad9 (patch)
tree8f548339b0bd8ba3fe5b254a254d3c7c5635b62b /service
parent165bd68065ea2ba698ec690dd057a474a4d860ae (diff)
Neissi / Duda - break leap mail header in multiple recipients
Diffstat (limited to 'service')
-rw-r--r--service/pixelated/adapter/pixelated_mail.py10
-rw-r--r--service/test/adapter/pixelated_mail_test.py20
2 files changed, 28 insertions, 2 deletions
diff --git a/service/pixelated/adapter/pixelated_mail.py b/service/pixelated/adapter/pixelated_mail.py
index 6d460626..cf0e12a5 100644
--- a/service/pixelated/adapter/pixelated_mail.py
+++ b/service/pixelated/adapter/pixelated_mail.py
@@ -53,12 +53,18 @@ class PixelatedMail:
def _extract_status(self):
return Status.from_flags(self.leap_mail.getFlags())
+ def _split_recipients(self, header_type, temporary_headers):
+ if(temporary_headers.get(header_type) is not None):
+ recipients = temporary_headers[header_type].split(',')
+ temporary_headers[header_type] = map (lambda x: x.replace(' ', ''), recipients)
+
def _extract_headers(self):
temporary_headers = {}
for header, value in self.leap_mail.hdoc.content['headers'].items():
temporary_headers[header.lower()] = value
- if(temporary_headers.get('to') is not None):
- temporary_headers['to'] = [temporary_headers['to']]
+
+ map(lambda x: self._split_recipients(x, temporary_headers), ['to', 'bcc','cc'])
+
return temporary_headers
def _extract_tags(self):
diff --git a/service/test/adapter/pixelated_mail_test.py b/service/test/adapter/pixelated_mail_test.py
index e3ebf727..77f9738f 100644
--- a/service/test/adapter/pixelated_mail_test.py
+++ b/service/test/adapter/pixelated_mail_test.py
@@ -87,3 +87,23 @@ class TestPixelatedMail(unittest.TestCase):
smtp_format = mail.to_smtp_format(_from='pixelated@org')
self.assertRegexpMatches(smtp_format, "\nFrom: pixelated@org")
+
+ def test_extract_headers_should_break_header_in_multiple_recipients(self):
+ headers = test_helper.DEFAULT_HEADERS.copy()
+ headers['to'] = "nlima@example.com, ddornelles@example.com"
+ headers['bcc'] = "nlima@example.com, ddornelles@example.com"
+ headers['cc'] = "nlima@example.com, ddornelles@example.com"
+
+ leap_mail = test_helper.leap_mail(headers=headers)
+
+ pixelated_mail = PixelatedMail.from_leap_mail(leap_mail)
+
+ self.assertEquals(pixelated_mail.headers['to'], ["nlima@example.com", "ddornelles@example.com" ])
+ self.assertEquals(pixelated_mail.headers['bcc'], ["nlima@example.com", "ddornelles@example.com" ])
+ self.assertEquals(pixelated_mail.headers['cc'], ["nlima@example.com", "ddornelles@example.com" ])
+
+
+
+
+
+