From 20dd16734f3794f40530d2d0fbc296051a80fa24 Mon Sep 17 00:00:00 2001 From: BordedDev <> Date: Sat, 31 May 2025 23:29:45 +0200 Subject: [PATCH] Cleaned up push register handler --- src/snek/view/push.py | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/src/snek/view/push.py b/src/snek/view/push.py index 9129ba6..fa19e54 100644 --- a/src/snek/view/push.py +++ b/src/snek/view/push.py @@ -27,7 +27,7 @@ import base64 import json -import requests +import aiohttp from cryptography.hazmat.primitives import serialization from snek.system.view import BaseFormView @@ -49,9 +49,6 @@ class PushView(BaseFormView): ) async def post(self): - memberships = [] - user = {} - user_id = self.session.get("uid") if user_id: user = await self.app.services.user.get(uid=user_id) @@ -102,18 +99,14 @@ class PushView(BaseFormView): "TTL": "60", } - print(headers) + async with aiohttp.ClientSession() as session: + async with session.post( + body["endpoint"], + headers=headers, + data=notification_info["data"], + ) as post_notification: + print(post_notification.status) + print(post_notification.text) + print(post_notification.headers) - post_notification = requests.post( - body["endpoint"], headers=headers, data=notification_info["data"] - ) - - print(post_notification.status_code) - print(post_notification.text) - print(post_notification.headers) - - return await self.json_response( - { - "registered": True, - } - ) \ No newline at end of file + return await self.json_response({ "registered": True }) \ No newline at end of file