diff options
Diffstat (limited to 'backend')
| -rw-r--r-- | backend/notif.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/backend/notif.py b/backend/notif.py index 59c6ec1..d2e1f2e 100644 --- a/backend/notif.py +++ b/backend/notif.py @@ -25,6 +25,12 @@ CREATE TABLE IF NOT EXISTS subscriptions ( # --- subscribe def subscribe(data: PushSubscriptionData): + cursor.execute("SELECT * FROM subscriptions WHERE endpoint = ?", (data.endpoint,)) + row = cursor.fetchall() + + if len(row) > 0: + return data.endpoint + cursor.execute(""" INSERT INTO subscriptions (endpoint, keys_p256dh, keys_auth) VALUES (?, ?, ?)""", (data.endpoint, data.keys["p256dh"], data.keys["auth"])) |
