From bb32c1f7f60fc2dcb1b08e5501bd9edac4a08546 Mon Sep 17 00:00:00 2001 From: spinline Date: Fri, 13 Feb 2026 12:31:06 +0300 Subject: [PATCH] fix: improve push notification reliability by removing invalid subscriptions and update rTorrent webhook logging --- backend/src/push.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/backend/src/push.rs b/backend/src/push.rs index 098bdf3..9aa19f9 100644 --- a/backend/src/push.rs +++ b/backend/src/push.rs @@ -192,10 +192,22 @@ pub async fn send_push_notification( } Err(e) => { tracing::error!("Failed to send push notification to {}: {}", subscription.endpoint, e); + // If subscription is invalid/expired (Gone or Unauthorized), remove it + if format!("{:?}", e).contains("Unauthorized") || format!("{:?}", e).contains("Gone") { + tracing::info!("Removing invalid subscription: {}", subscription.endpoint); + let _ = store.remove_subscription(&subscription.endpoint).await; + } } } } - Err(e) => tracing::error!("Failed to build push message: {}", e), + Err(e) => { + tracing::error!("Failed to build push message: {}", e); + // Specific handling for encryption errors - often means invalid keys + if format!("{:?}", e).contains("encrypting") { + tracing::warn!("Encryption error for subscriber {}, removing suspect subscription", subscription.endpoint); + let _ = store.remove_subscription(&subscription.endpoint).await; + } + } } } Err(e) => tracing::error!("Failed to build VAPID signature: {}", e),