From 3ed3148b8a73260097721a4e9caefe992a739cce Mon Sep 17 00:00:00 2001 From: AIIrondev Date: Wed, 29 Jul 2026 00:10:12 +0200 Subject: [PATCH] Fix of the notifikationssystem --- Web/push_notifications.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Web/push_notifications.py b/Web/push_notifications.py index 578fdb3..e8648ce 100644 --- a/Web/push_notifications.py +++ b/Web/push_notifications.py @@ -40,14 +40,18 @@ try: else: vapid = Vapid.from_file(VAPID_PRIVATE_PEM) - # Extract public key in standard uncompressed point format encoded in URL-safe base64 raw_pub = vapid.public_key.public_bytes( serialization.Encoding.X962, serialization.PublicFormat.UncompressedPoint ) - VAPID_PUBLIC_KEY = b64urlencode(raw_pub).decode('utf-8') - VAPID_PRIVATE_KEY = VAPID_PRIVATE_PEM # pywebpush accepts the file path to the private PEM + encoded_pub = b64urlencode(raw_pub) + if isinstance(encoded_pub, bytes): + VAPID_PUBLIC_KEY = encoded_pub.decode('utf-8') + else: + VAPID_PUBLIC_KEY = encoded_pub + + VAPID_PRIVATE_KEY = VAPID_PRIVATE_PEM except Exception as e: logger.error(f'Could not load or generate VAPID keys: {e}')