Cleaned up push register handler

This commit is contained in:
BordedDev 2025-05-31 23:29:45 +02:00
parent b01665f02c
commit 20dd16734f
No known key found for this signature in database
GPG Key ID: C5F495EAE56673BF

View File

@ -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,
}
)
return await self.json_response({ "registered": True })