summaryrefslogtreecommitdiff
path: root/service/pixelated/adapter/search
diff options
context:
space:
mode:
authorFolker Bernitt <fbernitt@thoughtworks.com>2015-08-11 10:17:55 +0200
committerFolker Bernitt <fbernitt@thoughtworks.com>2015-08-11 17:00:34 +0200
commit2f7aa40d6f48f725eca629ff8a47eb8922467032 (patch)
treedefb0da3c392059ac2e679664bc985d78f20709a /service/pixelated/adapter/search
parent9ed58715616f5c6341d32c9b0316933d3f2b4a3e (diff)
Fixed unit test.
Diffstat (limited to 'service/pixelated/adapter/search')
-rw-r--r--service/pixelated/adapter/search/__init__.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/service/pixelated/adapter/search/__init__.py b/service/pixelated/adapter/search/__init__.py
index e1ce5e8c..46691926 100644
--- a/service/pixelated/adapter/search/__init__.py
+++ b/service/pixelated/adapter/search/__init__.py
@@ -129,9 +129,9 @@ class SearchEngine(object):
'sender': self._unicode_header_field(header.get('from', '')),
'subject': self._unicode_header_field(header.get('subject', '')),
'date': milliseconds(header.get('date', '')),
- 'to': u','.join([h for h in header.get('to', [''])]),
- 'cc': u','.join([h for h in header.get('cc', [''])]),
- 'bcc': u','.join([h for h in header.get('bcc', [''])]),
+ 'to': self._format_recipient(header, 'to'),
+ 'cc': self._format_recipient(header, 'cc'),
+ 'bcc': self._format_recipient(header, 'bcc'),
'tag': u','.join(unique(tags)),
'bounced': u','.join(bounced),
'body': unicode(mdict['textPlainBody'] if 'textPlainBody' in mdict else mdict['body']),
@@ -142,6 +142,10 @@ class SearchEngine(object):
writer.update_document(**index_data)
+ def _format_recipient(self, headers, name):
+ list = headers.get(name, [''])
+ return u','.join(list) if list else u''
+
def _unicode_header_field(self, field_value):
if not field_value:
return None