summaryrefslogtreecommitdiff
path: root/backend/main.py
diff options
context:
space:
mode:
authoraltaf-creator <dev@altafcreator.com>2026-01-08 23:30:38 +0800
committeraltaf-creator <dev@altafcreator.com>2026-01-08 23:30:38 +0800
commit36a1e21e3d85fd1faa70a60b1515826a551d2e28 (patch)
tree553cf42c2963f3d55a708e6b4fd7b290058b39a5 /backend/main.py
parentfab2fc6a2c82d24d885483e751b715fe4b3abd89 (diff)
fix when reminder timer finished, already changed status to finished although not
Diffstat (limited to 'backend/main.py')
-rw-r--r--backend/main.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/backend/main.py b/backend/main.py
index 5f460e4..8dc6470 100644
--- a/backend/main.py
+++ b/backend/main.py
@@ -193,9 +193,6 @@ def reminder_timer_finished(timer_id):
cursor.execute("SELECT * FROM timers WHERE timer_id = ?", (timer_id,))
out = cursor.fetchall()
print(out)
-
- for row in out:
- machine_status[row[RowIndices.BLOCK] - 1][row[RowIndices.MACHINE] - 1] = Status.FINISHED.name
scheduler.add_job(final_timer_finished, 'date', run_date=out[0][RowIndices.END_TIME], id=str(timer_id), args=[timer_id])
@@ -455,6 +452,11 @@ def uri_to_information(data: InformationRequestData, response: fastapi.Response,
# --- subscribe
@app.post("/notifsubscribe", response_class=PlainTextResponse)
def notif_subscribe(data: notif.PushSubscriptionData, response: fastapi.Response):
- endpoint = notif.subscribe(data)
- response.set_cookie(key="subscription_endpoint", value=endpoint, max_age=COOKIE_MAX_AGE, domain="laundryweb.altafcreator.com", samesite="none", secure=True, path="/")
- return "do i need to return something perhaps"
+ try:
+ endpoint = notif.subscribe(data)
+ response.set_cookie(key="subscription_endpoint", value=endpoint, max_age=COOKIE_MAX_AGE, domain="laundryweb.altafcreator.com", samesite="none", secure=True, path="/")
+ response.status_code = fastapi.status.HTTP_200_OK
+ return "subscription saved."
+ except Exception as err:
+ response.status_code = fastapi.status.HTTP_500_INTERNAL_SERVER_ERROR
+ return f"error, failed to save subscription {err}"