Skip to content

Commit

Permalink
modifed __add_initial_message_headers to output the expected format f…
Browse files Browse the repository at this point in the history
…or the "to" and "cc" keys
  • Loading branch information
benne238 committed Jun 29, 2021
1 parent c7e0d0a commit 0f69c18
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/webqueue2api/parser/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def __init__(self, queue: str, number: int, headers_only: bool = False) -> None:
self.path = Path(config.queue_directory, self.queue, str(self.number))
if not self.path.exists():
raise ItemDoesNotExistError(str(self.path))

self.last_updated = self.__get_time_last_updated()
self.__raw_item = self.__get_raw_item()
self.headers = self.__parse_headers()
Expand Down Expand Up @@ -222,7 +222,7 @@ def __parseSections(self) -> list:

# Parse body
body_sections = parse_item(raw_item_as_string)

return body_sections

def __add_initial_message_headers(self, initial_message: dict) -> dict:
Expand All @@ -237,11 +237,20 @@ def __add_initial_message_headers(self, initial_message: dict) -> dict:
Returns:
dict: modified initial message dictionary to include headers
"""
raw_cc = self.__get_most_recent_header_by_type("CC")
raw_to = self.__get_most_recent_header_by_type("To")

initial_message["datetime"] = self.date_received
initial_message["from_name"] = self.user_name
initial_message["from_email"] = self.user_email
initial_message["to"] = self.__get_most_recent_header_by_type("To")
initial_message["cc"] = self.__get_most_recent_header_by_type("CC")
initial_message["to"] = [
{ "name": user_name, "email": user_email }
for user_name, user_email in email.utils.getaddresses([raw_to])
]
initial_message["cc"] = [
{ "name": user_name, "email": user_email }
for user_name, user_email in email.utils.getaddresses([raw_cc])
]
initial_message["subject"] = self.subject

return initial_message
Expand Down

0 comments on commit 0f69c18

Please sign in to comment.