Updated conditional check
This commit is contained in:
parent
744d0ace84
commit
272998f757
@ -63,12 +63,14 @@ class PushView(BaseFormView):
|
|||||||
|
|
||||||
body = await self.request.json()
|
body = await self.request.json()
|
||||||
|
|
||||||
if not (
|
if not all(
|
||||||
"encoding" in body
|
[
|
||||||
and "endpoint" in body
|
"encoding" in body,
|
||||||
and "keys" in body
|
"endpoint" in body,
|
||||||
and "p256dh" in body["keys"]
|
"keys" in body,
|
||||||
and "auth" in body["keys"]
|
"p256dh" in body["keys"],
|
||||||
|
"auth" in body["keys"],
|
||||||
|
]
|
||||||
):
|
):
|
||||||
return await self.json_response(
|
return await self.json_response(
|
||||||
{"error": "Invalid request"}, status=400
|
{"error": "Invalid request"}, status=400
|
||||||
@ -85,7 +87,7 @@ class PushView(BaseFormView):
|
|||||||
}
|
}
|
||||||
|
|
||||||
notification_info = notifications.create_notification_info_with_payload(
|
notification_info = notifications.create_notification_info_with_payload(
|
||||||
body['endpoint'],
|
body["endpoint"],
|
||||||
body["keys"]["auth"],
|
body["keys"]["auth"],
|
||||||
body["keys"]["p256dh"],
|
body["keys"]["p256dh"],
|
||||||
json.dumps(test_payload),
|
json.dumps(test_payload),
|
||||||
@ -98,7 +100,9 @@ class PushView(BaseFormView):
|
|||||||
|
|
||||||
print(headers)
|
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.status_code)
|
||||||
print(post_notification.text)
|
print(post_notification.text)
|
||||||
|
Loading…
Reference in New Issue
Block a user