Skip to content

Commit

Permalink
Merge pull request #137 from DataFactory-Verlingue/deal_with_draft_in…
Browse files Browse the repository at this point in the history
…_file_tree

[#136] Deal with draft in file tree
  • Loading branch information
hugo-quantmetry authored Dec 5, 2022
2 parents efbdc33 + 8a67dfe commit 7e4a6ea
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions melusine/connectors/exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,15 +364,28 @@ def _extract_email_attributes(email_item: Message) -> dict:
else:
attachments_list = [i.name for i in email_item.attachments]

email_dict = {
"message_id": email_item.message_id,
"body": email_item.text_body or "",
"header": email_item.subject or "",
"date": email_item.datetime_sent.isoformat(),
"from": email_item.sender.email_address or None,
"to": to_list,
"attachment": attachments_list,
}
# Modification to deal with draft in file tree
if email_item.datetime_sent != None and email_item.sender != None:
email_dict = {
"message_id": email_item.message_id,
"body": email_item.text_body or "",
"header": email_item.subject or "",
"date": email_item.datetime_sent.isoformat(),
"from": email_item.sender.email_address or None,
"to": to_list,
"attachment": attachments_list,
}
else:
# There is a draft in the emails
email_dict = {
"message_id": email_item.message_id,
"body": email_item.body or "",
"header": email_item.subject or "",
"date": None,
"from": None,
"to": None,
"attachment": attachments_list,
}
return email_dict

def route_emails(
Expand Down

0 comments on commit 7e4a6ea

Please sign in to comment.