diff --git a/api/ECNQueue.py b/api/ECNQueue.py index 51a8139..b3abb35 100644 --- a/api/ECNQueue.py +++ b/api/ECNQueue.py @@ -632,6 +632,17 @@ def __userReplyParsing(self, replyContent: list, lineNumber: int) -> dict: errorMessage = "Did not encounter a reply-from-user ending delimiter" return self.__errorParsing(line, lineNumber + lineNum + 1, errorMessage) + if newLineCounter == 1 and line != "\n": + + # Append header information for each headr line + headerType, content = line.split(": ", 1) + replyFromHeaders.append( + {"type": headerType, + "content": content + } + ) + + linesToRemove.append(lineNum) #Checks for a newline and breaks for loop on second occurance of a newline if line == "\n": newLineCounter = newLineCounter + 1 @@ -645,7 +656,6 @@ def __userReplyParsing(self, replyContent: list, lineNumber: int) -> dict: replyFromInfo["from_name"] = emailList[0][0] replyFromInfo["from_email"] = emailList[0][1] - linesToRemove.append(lineNum) elif line.startswith("Subject: ") and newLineCounter == 1: # Matches everything after "Subject: " try: @@ -657,8 +667,6 @@ def __userReplyParsing(self, replyContent: list, lineNumber: int) -> dict: # Formatts the date to UTC replyFromInfo["subject"] = subjectStr - linesToRemove.append(lineNum) - elif line.startswith("Date: ") and newLineCounter == 1: # Matches everything after "Date: " try: @@ -670,8 +678,6 @@ def __userReplyParsing(self, replyContent: list, lineNumber: int) -> dict: # Formatts the date to UTC replyFromInfo["datetime"] = self.__getFormattedDate(dateStr) - linesToRemove.append(lineNum) - elif line.startswith("Cc: ") and newLineCounter == 1: replyFromInfo["cc"] = [] @@ -685,9 +691,7 @@ def __userReplyParsing(self, replyContent: list, lineNumber: int) -> dict: replyFromInfo["cc"].append( {"name": cc[0], "email": cc[1]} - ) - - linesToRemove.append(lineNum) + ) # Deletes reduntant lines from the message content in reverse order for lineNum in sorted(linesToRemove, reverse = True): @@ -696,6 +700,8 @@ def __userReplyParsing(self, replyContent: list, lineNumber: int) -> dict: # Strips any unnecessary newlines or any delimiters frm the message content replyFromInfo["content"] = self.__getFormattedMessageContent(replyContent) + replyFromInfo["headers"] = replyFromHeaders + return replyFromInfo def __getFormattedMessageContent(self, messageContent: list) -> list: