Skip to content

Commit

Permalink
bugfix for item.__getUserAlias() function
Browse files Browse the repository at this point in the history
  • Loading branch information
benne238 committed Feb 1, 2021
1 parent fc90e73 commit 73a930c
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions api/ECNQueue.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
currentFileDirectory = os.path.dirname(currentFilePath)
currentFileDirectoryParent = os.path.dirname(currentFileDirectory)
queueDirectory = os.path.join(currentFileDirectoryParent, "q-snapshot")
queueDirectory = "/home/pier/e/queue/Mail"

# Queues to not load in getQueues()
queuesToIgnore = ["archives", "drafts", "inbox", "coral"]
Expand Down Expand Up @@ -1200,7 +1201,18 @@ def __getUserAlias(self) -> str:
Returns:
str: User's Career Account alias if present or empty string
"""
emailUser, emailDomain = self.userEmail.split("@")

# Returns an error parse if the useremail isn't valid
try:
emailUser, emailDomain = self.userEmail.split("@")

except:
# Parses through the self.headers list to find the "From" header and its line number
for lineNum, header in enumerate(self.headers):
if header["type"] == "From":
headerString = header["type"] + ": " + header["content"]
return self.__errorParsing(headerString, lineNum + 1, "Expected valid email Address")

return emailUser if emailDomain.endswith("purdue.edu") else ""

def __getFormattedDate(self, date: str) -> str:
Expand Down Expand Up @@ -1355,4 +1367,8 @@ def loadQueues() -> list:
for queue in getValidQueues():
queues.append(Queue(queue))

return queues
return queues

if __name__ == "__main__":
item = Item("me", 105)
print()

0 comments on commit 73a930c

Please sign in to comment.