summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/notif.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/backend/notif.py b/backend/notif.py
index 00a1b63..09a6e44 100644
--- a/backend/notif.py
+++ b/backend/notif.py
@@ -27,9 +27,14 @@ CREATE TABLE IF NOT EXISTS subscriptions (
# --- subscribe
def subscribe(data: PushSubscriptionData):
- cursor.execute("""
- INSERT INTO subscriptions (endpoint, expiration_time, keys_p256dh, keys_auth)
- VALUES (?, ?, ?, ?)""", (data.endpoint, data.expirationTime, data.keys["p256dh"], data.keys["auth"]))
+ if data.expirationTime:
+ cursor.execute("""
+ INSERT INTO subscriptions (endpoint, expiration_time, keys_p256dh, keys_auth)
+ VALUES (?, ?, ?, ?)""", (data.endpoint, data.expirationTime, data.keys["p256dh"], data.keys["auth"]))
+ else:
+ cursor.execute("""
+ INSERT INTO subscriptions (endpoint, keys_p256dh, keys_auth)
+ VALUES (?, ?, ?, ?)""", (data.endpoint, data.keys["p256dh"], data.keys["auth"]))
conn.commit()
return data.endpoint