summaryrefslogtreecommitdiff
path: root/backend/notif.py
diff options
context:
space:
mode:
Diffstat (limited to 'backend/notif.py')
-rw-r--r--backend/notif.py6
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"]))