generated from nathanwoodburn/python-webserver-template
Compare commits
4 Commits
0ce3f9c629
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
415806e852
|
|||
|
3b118e6923
|
|||
|
5c6f049fb4
|
|||
|
4e7bc0335c
|
16
server.py
16
server.py
@@ -95,7 +95,7 @@ def login():
|
||||
# Get username and token from args
|
||||
token = request.args.get("token")
|
||||
# Set token cookie
|
||||
response = make_response(redirect("/inbox"))
|
||||
response = make_response(redirect("/refresh"))
|
||||
response.set_cookie("token", token)
|
||||
return response
|
||||
|
||||
@@ -205,6 +205,9 @@ def save_notification_settings(email, webhook, email_alert):
|
||||
def get_notification_settings(email):
|
||||
if not os.path.exists(notification_file):
|
||||
return False
|
||||
|
||||
# Reformat email
|
||||
email = email.split('@')[0] + '@login.hns.au'
|
||||
|
||||
with open(notification_file, "r") as f:
|
||||
data = json.load(f)
|
||||
@@ -228,9 +231,11 @@ def delete_email(conversation_id, email):
|
||||
headers = {
|
||||
"X-FreeScout-API-Key": os.getenv("FREESCOUT_API_KEY"),
|
||||
}
|
||||
altemail:str = f"{email.split('@')[0]}@e.hns.au"
|
||||
|
||||
for thread in conversation:
|
||||
for message in thread["messages"]:
|
||||
if email in message["to"]:
|
||||
if email in message["to"] or altemail in message["to"]:
|
||||
requests.delete(
|
||||
f"https://ticket.woodburn.au/api/conversations/{thread['id']}", headers=headers)
|
||||
clear_cache()
|
||||
@@ -370,7 +375,8 @@ def get_user(token):
|
||||
|
||||
|
||||
@cache
|
||||
def get_email(email):
|
||||
def get_email(email:str):
|
||||
altemail:str = f"{email.split('@')[0]}@e.hns.au"
|
||||
params = {
|
||||
"embed": "threads",
|
||||
"mailboxId": os.getenv("FREESCOUT_MAILBOX"),
|
||||
@@ -396,10 +402,10 @@ def get_email(email):
|
||||
for conversation in conversations["_embedded"]["conversations"]:
|
||||
addresses = conversation["cc"]
|
||||
for address in addresses:
|
||||
if address == email:
|
||||
if address == email or address == altemail:
|
||||
threads.append(parse_email(conversation))
|
||||
|
||||
return {"email": email, "conversations": threads}
|
||||
return {"email": email, "emailalt": altemail,"conversations": threads}
|
||||
|
||||
|
||||
@cache
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<body>
|
||||
<header style="display: inline;">
|
||||
<img src="/favicon.png" style="width:50px;height:50px;">
|
||||
<h1>HNS Email</h1> <span style="float:right">{{emails.email}} | <a href="/notifications">Notifications</a> | <a
|
||||
<h1>HNS Email</h1> <span style="float:right">{{emails.email}} {{emails.emailalt}} | <a href="/notifications">Notifications</a> | <a
|
||||
href="/logout">Logout</a></span>
|
||||
</header>
|
||||
<br>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<body>
|
||||
<header style="display: inline;">
|
||||
<img src="/favicon.png" style="width:50px;height:50px;">
|
||||
<h1>HNS Email</h1> <span style="float:right">{{email}} | <a href="/inbox">Inbox</a> | <a
|
||||
<h1>HNS Email</h1> <span style="float:right">{{email}} | <a href="/inbox">Inbox</a> | <a
|
||||
href="/logout">Logout</a></span>
|
||||
</header>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user