diff options
| author | altaf-creator <dev@altafcreator.com> | 2025-12-29 21:40:14 +0800 |
|---|---|---|
| committer | altaf-creator <dev@altafcreator.com> | 2025-12-29 21:40:14 +0800 |
| commit | 145bf5aef90e65a8d01cf701ae4cf0f37016c075 (patch) | |
| tree | 14eb1be16d026f57ed9b7f995cea61b96722c168 /backend/notif.py | |
| parent | 1d96fea188f43554f6d434ffc0302576c1a40af2 (diff) | |
ignore if sub already exist in db
Diffstat (limited to 'backend/notif.py')
| -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"])) |
