diff --git a/api/ECNQueue.py b/api/ECNQueue.py index 51654b8..45a24b3 100644 --- a/api/ECNQueue.py +++ b/api/ECNQueue.py @@ -47,8 +47,8 @@ def __init__(self, queue: str, number: int) -> None: self.userName = self.__parseFromData(data="userName") self.userAlias = self.__getUserAlias() self.assignedTo = self.__getAssignedTo() - self.subject = self.__getMostRecentHeaderByType("Subject")["content"] - self.status = self.__getMostRecentHeaderByType("Status")["content"] + self.subject = self.__getMostRecentHeaderByType("Subject") + self.status = self.__getMostRecentHeaderByType("Status") self.jsonData = { "lastUpdated": self.lastUpdated, @@ -185,35 +185,27 @@ def __isLocked(self) -> Union[str, bool]: else: return False - def __getMostRecentHeaderByType(self, headerType: str) -> dict: - """Return most recent header of the given type. - If no header of that type exists, return a header with the type requests and empty content. + def __getMostRecentHeaderByType(self, headerType: str) -> str: + """Return the data of most recent header of the given type. + If no header of that type exists, return an empty string. Example: Requesting a Status header that does exist __getMostRecentHeaderByType("Status") - becomes - { - "type": "Status", - "content": "Waiting for Reply" - } + becomes "Waiting for Reply" Example: Requesting a Status header that doesn't exist __getMostRecentHeaderByType("Status") - becomes - { - "type": "Status", - "content": "" - } + becomes "" Args: headerType (str): Type of header to return. Returns: - dict: dict of header if it exists or dict of requested type with empty content. + str: data of most recent header of the given type or empty string. """ for header in self.headers: - if header["type"] == headerType: return header - return { "type": headerType, "content": "" } + if header["type"] == headerType: return header["content"] + return "" def __parseFromData(self, data: str) -> str: """Parse From header and return requested data. @@ -230,7 +222,7 @@ def __parseFromData(self, data: str) -> str: str: userName, userEmail or empty string. """ fromHeader = self.__getMostRecentHeaderByType("From") - userName, userEmail = email.utils.parseaddr(fromHeader["content"]) + userName, userEmail = email.utils.parseaddr(fromHeader) if data == "userName": return userName elif data == "userEmail": return userEmail @@ -259,8 +251,7 @@ def __getAssignedTo(self) -> str: Returns: str: Alias of the person item is assigned to or empty string. """ - assignedToHeader = self.__getMostRecentHeaderByType("Assigned-To") - assignedTo = assignedToHeader["content"] + assignedTo = self.__getMostRecentHeaderByType("Assigned-To") return assignedTo def toJson(self) -> dict: