Updated conditional check
This commit is contained in:
		
							parent
							
								
									744d0ace84
								
							
						
					
					
						commit
						272998f757
					
				@ -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)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user