Cleaned up push register handler
This commit is contained in:
		
							parent
							
								
									b01665f02c
								
							
						
					
					
						commit
						20dd16734f
					
				| @ -27,7 +27,7 @@ | |||||||
| import base64 | import base64 | ||||||
| import json | import json | ||||||
| 
 | 
 | ||||||
| import requests | import aiohttp | ||||||
| from cryptography.hazmat.primitives import serialization | from cryptography.hazmat.primitives import serialization | ||||||
| 
 | 
 | ||||||
| from snek.system.view import BaseFormView | from snek.system.view import BaseFormView | ||||||
| @ -49,9 +49,6 @@ class PushView(BaseFormView): | |||||||
|         ) |         ) | ||||||
| 
 | 
 | ||||||
|     async def post(self): |     async def post(self): | ||||||
|         memberships = [] |  | ||||||
|         user = {} |  | ||||||
| 
 |  | ||||||
|         user_id = self.session.get("uid") |         user_id = self.session.get("uid") | ||||||
|         if user_id: |         if user_id: | ||||||
|             user = await self.app.services.user.get(uid=user_id) |             user = await self.app.services.user.get(uid=user_id) | ||||||
| @ -102,18 +99,14 @@ class PushView(BaseFormView): | |||||||
|                     "TTL": "60", |                     "TTL": "60", | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|                 print(headers) |                 async with aiohttp.ClientSession() as session: | ||||||
| 
 |                     async with session.post( | ||||||
|                 post_notification = requests.post( |                         body["endpoint"], | ||||||
|                     body["endpoint"], headers=headers, data=notification_info["data"] |                         headers=headers, | ||||||
|                 ) |                         data=notification_info["data"], | ||||||
| 
 |                     ) as post_notification: | ||||||
|                 print(post_notification.status_code) |                         print(post_notification.status) | ||||||
|                         print(post_notification.text) |                         print(post_notification.text) | ||||||
|                         print(post_notification.headers) |                         print(post_notification.headers) | ||||||
| 
 | 
 | ||||||
|         return await self.json_response( |         return await self.json_response({ "registered": True }) | ||||||
|             { |  | ||||||
|                 "registered": True, |  | ||||||
|             } |  | ||||||
|         ) |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 BordedDev
						BordedDev