Skip to content

Commit

Permalink
Update dictionary keys for each parsed section per github issue #2
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Daniel Bennett committed Oct 5, 2020
1 parent 8e150c0 commit 429213f
Showing 1 changed file with 32 additions and 17 deletions.
49 changes: 32 additions & 17 deletions api/ECNQueue.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,22 @@ def __parseSections(self) -> list:
# Formats the initial message date to UTC
initialMessageFormattedDate = self.__getFormattedDate(initialMessageDateStr)

# Stores list of dictionaries for the recipients of the initial message
initialMessageRecipientsSection = []

# Parses the header looking for recipients of the initial message and stores it in a list of tuples
initialMessageRecipientsList = email.utils.getaddresses([self.__getMostRecentHeaderByType("To")])

# Parses the CC list and stores the cc recipient information in a list of dictionaries
for recipients in initialMessageRecipientsList:

initialMessageRecipientsSection.append(
{"name": recipients[0],
"email": recipients[1]}
)

# Stores list of dictionaries for CC information
initialMessageCCSection =[]
initialMessageCCSection = []

# Parses the header looking for CC recipients of the initial message and stores it in a list of tuples
initialMessageCCList = email.utils.getaddresses([self.__getMostRecentHeaderByType("CC")])
Expand All @@ -284,11 +298,12 @@ def __parseSections(self) -> list:

# Appends all initial message information to the sections array
sections.append(
{"type": "initialMessage",
{"type": "initial_message",
"datetime": initialMessageFormattedDate,
"userName": self.__parseFromData(data="userName"),
"userEmail": self.__parseFromData(data="userEmail"),
"ccRecipients": initialMessageCCSection,
"from_name": self.__parseFromData(data="userName"),
"user_email": self.__parseFromData(data="userEmail"),
"to": initialMessageRecipientsSection,
"cc": initialMessageCCSection,
"content": initialMessageContent}
)

Expand Down Expand Up @@ -321,9 +336,9 @@ def __parseSections(self) -> list:

# Appends the assignment to the sections list
sections.append(
{"type": "assign",
"by": assignedBy,
{"type": "assignment",
"datetime": assignedDateTime,
"by": assignedBy,
"to": assignedTo}
)

Expand Down Expand Up @@ -488,8 +503,8 @@ def __editParsing(self, line: str) -> dict:

editInfo = {
"type": "edit",
"by": editedBy,
"datetime": formattedDateTime,
"by": editedBy,
"content": ""
}

Expand All @@ -515,9 +530,9 @@ def __replyToParsing(self, line: str) -> dict:
formattedDateTime = self.__getFormattedDate(dateTimeString)

replyInfo = {
"type": "replyToUser",
"by": repliedBy,
"type": "reply_to_user",
"datetime": formattedDateTime,
"by": repliedBy,
"content": ""
}

Expand All @@ -544,8 +559,8 @@ def __statusParsing(self, line: str) -> dict:

statusInfo = {
"type": "status",
"by": updatedBy,
"datetime": formattedDateTime,
"by": updatedBy,
"content": ""
}

Expand Down Expand Up @@ -642,13 +657,13 @@ def __userReplyParsing(self, replyContent: list) -> dict:
replyContent = self.__getFormattedMessageContent(replyContent)

replyFromInfo = {
"type": "replyFromUser",
"type": "reply_from_user",
"datetime": formattedDateTime,
"subject": subject,
"userName": repliedByName,
"userEmail": repliedByEmail,
"content": replyContent,
"ccRecipients": ccRecipientsList
#"subject": subject,
"from_name": repliedByName,
"from_email": repliedByEmail,
"cc": ccRecipientsList,
"content": replyContent
}

return replyFromInfo
Expand Down

0 comments on commit 429213f

Please sign in to comment.