Check for key in props (#8)

This commit is contained in:
Alfredo
2019-05-22 12:20:10 +02:00
committed by Joshua Tauberer
parent a8e1e8f064
commit eee84c759f
+28 -15
View File
@@ -64,26 +64,39 @@ def load_message_stream(entry, is_top_level, doc):
else: else:
# Construct common headers from metadata. # Construct common headers from metadata.
msg['Date'] = formatdate(props['MESSAGE_DELIVERY_TIME'].timestamp()) if 'MESSAGE_DELIVERY_TIME' in props:
del props['MESSAGE_DELIVERY_TIME'] msg['Date'] = formatdate(props['MESSAGE_DELIVERY_TIME'].timestamp())
del props['MESSAGE_DELIVERY_TIME']
if props['SENDER_NAME'] != props['SENT_REPRESENTING_NAME']: if 'SENDER_NAME' in props:
props['SENDER_NAME'] += " (" + props['SENT_REPRESENTING_NAME'] + ")" if 'SENT_REPRESENTING_NAME' in props:
del props['SENT_REPRESENTING_NAME'] if props['SENT_REPRESENTING_NAME']:
msg['From'] = formataddr((props['SENDER_NAME'], "")) if props['SENDER_NAME'] != props['SENT_REPRESENTING_NAME']:
del props['SENDER_NAME'] props['SENDER_NAME'] += " (" + props['SENT_REPRESENTING_NAME'] + ")"
del props['SENT_REPRESENTING_NAME']
if props['SENDER_NAME']:
msg['From'] = formataddr((props['SENDER_NAME'], ""))
del props['SENDER_NAME']
msg['To'] = props['DISPLAY_TO'] if 'DISPLAY_TO' in props:
del props['DISPLAY_TO'] if props['DISPLAY_TO']:
msg['To'] = props['DISPLAY_TO']
del props['DISPLAY_TO']
msg['CC'] = props['DISPLAY_CC'] if 'DISPLAY_CC' in props:
del props['DISPLAY_CC'] if props['DISPLAY_CC']:
msg['CC'] = props['DISPLAY_CC']
del props['DISPLAY_CC']
msg['BCC'] = props['DISPLAY_BCC'] if 'DISPLAY_BCC' in props:
del props['DISPLAY_BCC'] if props['DISPLAY_BCC']:
msg['BCC'] = props['DISPLAY_BCC']
del props['DISPLAY_BCC']
msg['Subject'] = props['SUBJECT'] if 'SUBJECT' in props:
del props['SUBJECT'] if props['SUBJECT']:
msg['Subject'] = props['SUBJECT']
del props['SUBJECT']
# Add the plain-text body from the BODY field. # Add the plain-text body from the BODY field.
if 'BODY' in props: if 'BODY' in props: