feat/push-notifications #34

Merged
retoor merged 16 commits from :feat/push-notifications into main 2025-06-06 11:25:09 +02:00
Showing only changes of commit 272998f757 - Show all commits

View File

@ -63,12 +63,14 @@ class PushView(BaseFormView):
body = await self.request.json()
if not (
"encoding" in body
and "endpoint" in body
and "keys" in body
and "p256dh" in body["keys"]
and "auth" in body["keys"]
if not all(
[
"encoding" in body,
"endpoint" in body,
"keys" in body,
"p256dh" in body["keys"],
"auth" in body["keys"],
]
):
return await self.json_response(
{"error": "Invalid request"}, status=400
@ -85,7 +87,7 @@ class PushView(BaseFormView):
}
notification_info = notifications.create_notification_info_with_payload(
body['endpoint'],
body["endpoint"],
body["keys"]["auth"],
body["keys"]["p256dh"],
json.dumps(test_payload),
@ -98,7 +100,9 @@ class PushView(BaseFormView):
print(headers)
post_notification = requests.post(body["endpoint"], headers=headers, data=notification_info["data"])
post_notification = requests.post(
body["endpoint"], headers=headers, data=notification_info["data"]
)
print(post_notification.status_code)
print(post_notification.text)