diff options
| author | altaf-creator <dev@altafcreator.com> | 2025-12-29 20:36:59 +0800 |
|---|---|---|
| committer | altaf-creator <dev@altafcreator.com> | 2025-12-29 20:36:59 +0800 |
| commit | 500b43197c7e46fdcc82176431e52651ef37d05e (patch) | |
| tree | 922449c3a62e55ac7563ae42fc8e8deed51a39f3 | |
| parent | 034b151088886f8b6d306f37f8a770a23844f1ac (diff) | |
hmm
| -rw-r--r-- | backend/notif.py | 11 |
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 |
