summaryrefslogtreecommitdiff
path: root/service/pixelated/adapter
diff options
context:
space:
mode:
authorLisa Junger <ljunger@thoughtworks.com>2015-01-06 11:25:10 +0100
committerLisa Junger <ljunger@thoughtworks.com>2015-01-06 11:47:16 +0100
commitbd903ece01d9a1f85f3459f6495ad342bb64500e (patch)
tree978219d5b1668fc83d3346afae9d0cdea60e2526 /service/pixelated/adapter
parente36e4e95b80b8ac2265136f12d16510877db4282 (diff)
Issue #215: Fixed missing From header for sent mails.
- Fixes problem with trailing comma for reply all
Diffstat (limited to 'service/pixelated/adapter')
-rw-r--r--service/pixelated/adapter/model/mail.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/service/pixelated/adapter/model/mail.py b/service/pixelated/adapter/model/mail.py
index 690137ff..4b128d8c 100644
--- a/service/pixelated/adapter/model/mail.py
+++ b/service/pixelated/adapter/model/mail.py
@@ -93,6 +93,9 @@ class InputMail(Mail):
self._bd = None
self._chash = None
self._mime = None
+ self.headers = {}
+ self.body = ''
+ self._status = []
@property
def ident(self):
@@ -126,13 +129,17 @@ class InputMail(Mail):
if self._hd:
return self._hd
+ # InputMail does not have a from header but we need it when persisted into soledad.
+ headers = self.headers.copy()
+ headers['From'] = InputMail.FROM_EMAIL_ADDRESS
+
hd = {}
- hd[fields.HEADERS_KEY] = self.headers
- hd[fields.DATE_KEY] = self.headers['Date']
+ hd[fields.HEADERS_KEY] = headers
+ hd[fields.DATE_KEY] = headers['Date']
hd[fields.CONTENT_HASH_KEY] = self._get_chash()
hd[fields.MSGID_KEY] = ''
hd[fields.MULTIPART_KEY] = True
- hd[fields.SUBJECT_KEY] = self.headers.get('Subject')
+ hd[fields.SUBJECT_KEY] = headers.get('Subject')
hd[fields.TYPE_KEY] = fields.TYPE_HEADERS_VAL
hd[fields.BODY_KEY] = self._get_body_phash()
hd[fields.PARTS_MAP_KEY] = \
@@ -350,7 +357,10 @@ class PixelatedMail(Mail):
'attachments': self.parts['attachments'] if self.parts else []}
dict_mail['replying'] = {'single': None, 'all': {'to-field': [], 'cc-field': []}}
- sender_mail = self.headers.get('Reply-To', self.headers['From'])
+ sender_mail = self.headers.get('Reply-To', self.headers.get('From'))
+ # Issue #215: Fix for existing mails without any from address.
+ if sender_mail is None:
+ sender_mail = InputMail.FROM_EMAIL_ADDRESS
recipients = [recipient for recipient in self.headers['To'] if recipient != InputMail.FROM_EMAIL_ADDRESS]
recipients.append(sender_mail)