Debug of Vapid Keys
This commit is contained in:
@@ -122,13 +122,17 @@ def get_user_subscriptions(username):
|
|||||||
|
|
||||||
|
|
||||||
def save_push_subscription(username, subscription_obj):
|
def save_push_subscription(username, subscription_obj):
|
||||||
"""Save a new push subscription for a user with field-level encryption."""
|
import traceback # Hilft uns, Fehler genau zu sehen
|
||||||
try:
|
try:
|
||||||
|
print("--- DEBUG PUSH PAYLOAD ---")
|
||||||
|
print(subscription_obj)
|
||||||
|
|
||||||
endpoint = subscription_obj.get('endpoint')
|
endpoint = subscription_obj.get('endpoint')
|
||||||
keys = subscription_obj.get('keys', {})
|
keys = subscription_obj.get('keys', {})
|
||||||
|
|
||||||
if not endpoint or not keys.get('p256dh') or not keys.get('auth'):
|
if not endpoint or not keys.get('p256dh') or not keys.get('auth'):
|
||||||
logger.warning(f'Invalid subscription object for {username}: missing endpoint or keys')
|
print(
|
||||||
|
f"DEBUG FEHLER: Keys fehlen! Endpoint: {bool(endpoint)}, p256dh: {bool(keys.get('p256dh'))}, auth: {bool(keys.get('auth'))}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
client = MongoClient(cfg.MONGODB_HOST, cfg.MONGODB_PORT)
|
client = MongoClient(cfg.MONGODB_HOST, cfg.MONGODB_PORT)
|
||||||
@@ -178,8 +182,10 @@ def save_push_subscription(username, subscription_obj):
|
|||||||
client.close()
|
client.close()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f'Error saving push subscription: {e}')
|
print(f"DEBUG ABSTURZ in save_push_subscription: {e}")
|
||||||
|
traceback.print_exc()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -161,15 +161,19 @@ class PushNotificationManager {
|
|||||||
try {
|
try {
|
||||||
const subscription = await this.serviceWorkerRegistration.pushManager.getSubscription();
|
const subscription = await this.serviceWorkerRegistration.pushManager.getSubscription();
|
||||||
if (!subscription) {
|
if (!subscription) {
|
||||||
console.warn('No active push subscription');
|
return true;
|
||||||
return true; // Bereits deaktiviert
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Best-Effort: Dem Server Bescheid geben (wir ignorieren absichtlich,
|
// Best-Effort: Server benachrichtigen (Eigener try/catch Block!)
|
||||||
// falls der Server das Abo nicht mehr kennt)
|
try {
|
||||||
await this.removeSubscriptionFromServer(subscription);
|
await this.removeSubscriptionFromServer(subscription);
|
||||||
|
} catch (serverError) {
|
||||||
|
// Fehler vom Server ignorieren wir absichtlich.
|
||||||
|
// Das Skript läuft weiter, statt hier abzubrechen!
|
||||||
|
console.warn('Server-Abmeldung fehlgeschlagen, lösche lokal trotzdem:', serverError);
|
||||||
|
}
|
||||||
|
|
||||||
// WICHTIG: Das Abo im Browser immer zwingend löschen!
|
// WICHTIG: Das hier wird jetzt garantiert ausgeführt
|
||||||
await subscription.unsubscribe();
|
await subscription.unsubscribe();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user