summaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
Diffstat (limited to 'backend')
-rw-r--r--backend/__pycache__/notif.cpython-314.pycbin0 -> 3607 bytes
-rw-r--r--backend/notif.py4
-rw-r--r--backend/notif_test.py23
3 files changed, 5 insertions, 22 deletions
diff --git a/backend/__pycache__/notif.cpython-314.pyc b/backend/__pycache__/notif.cpython-314.pyc
new file mode 100644
index 0000000..d8ed6c1
--- /dev/null
+++ b/backend/__pycache__/notif.cpython-314.pyc
Binary files differ
diff --git a/backend/notif.py b/backend/notif.py
index 1dc2b3c..96df3c1 100644
--- a/backend/notif.py
+++ b/backend/notif.py
@@ -37,7 +37,7 @@ def subscribe(data: PushSubscriptionData):
VALUES (?, ?, ?)""", (data.endpoint, data.keys["p256dh"], data.keys["auth"]))
conn.commit()
- cursor.execute("SELECT * FROM subscriptions");
+ cursor.execute("SELECT * FROM subscriptions")
result = cursor.fetchall()
for row in result:
@@ -49,7 +49,7 @@ def subscribe(data: PushSubscriptionData):
# --- send notification
# ---- not used yet
def send_notification(endpoint: str, notification_payload: object):
- cursor.execute("SELECT * FROM subscriptions WHERE endpoint = ?", (endpoint,))
+ cursor.execute(f"""SELECT * FROM subscriptions WHERE endpoint = \"{endpoint}\"""")
row = cursor.fetchall()[0]
print(row)
diff --git a/backend/notif_test.py b/backend/notif_test.py
index cf5391f..feabb7a 100644
--- a/backend/notif_test.py
+++ b/backend/notif_test.py
@@ -1,21 +1,4 @@
-from dotenv import load_dotenv
-from os import getenv
-import onesignal
-from onesignal.api import default_api
-from onesignal.model.notification import Notification
+import notif
-load_dotenv()
-
-onesignal_configuration = onesignal.Configuration(
- rest_api_key=getenv("REST_API_KEY"),
- organization_api_key=getenv("ORGANIZATION_API_KEY"),
-)
-
-api_client = onesignal.ApiClient(onesignal_configuration)
-api_instance = default_api.DefaultApi(api_client)
-
-ONESIGNAL_APP_ID = "83901cc7-d964-475a-90ec-9f854df4ba52"
-
-# yes that's my subscription id. probably outdated by now
-notification = Notification(app_id=ONESIGNAL_APP_ID, include_subscription_ids=['86f24e73-8887-4e29-b607-31e1a8f25b93'], contents={'en': 'hello world'}, headings={'en': 'Laundry Finished!'}, priority=10)
-print(api_instance.create_notification(notification))
+endpoint_to_test = "https://fcm.googleapis.com/fcm/send/c14_JXV1C_4:APA91bHzdw7uXAJdjb0mZMwFS_j3Y1NEpbXUS9n4TEwak3zLcDFZjjKpJHkPdZC-2FCWL7aeIUYL9w18ZppDX3mec-lA48b-bPnOJr5GSh6AYaq4zFtu_nM3u4aVoN_ga1pFwtCEqTm8"
+notif.send_notification(endpoint_to_test, {"title": "This is a test", "body": "Hello, world!"})