fix: ensure problematic push subscriptions are always removed on any error
All checks were successful
Build MIPS Binary / build (push) Successful in 1m51s
All checks were successful
Build MIPS Binary / build (push) Successful in 1m51s
This commit is contained in:
@@ -191,30 +191,20 @@ pub async fn send_push_notification(
|
|||||||
tracing::debug!("Push notification sent to: {}", subscription.endpoint);
|
tracing::debug!("Push notification sent to: {}", subscription.endpoint);
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
tracing::error!("Failed to send push notification to {}: {}", subscription.endpoint, e);
|
let err_msg = format!("{:?}", e);
|
||||||
// If subscription is invalid/expired (Gone or Unauthorized), remove it
|
tracing::error!("Delivery failed for {}: {}", subscription.endpoint, err_msg);
|
||||||
if format!("{:?}", e).contains("Unauthorized") || format!("{:?}", e).contains("Gone") {
|
// Always remove on delivery failure (Gone, Unauthorized, etc.)
|
||||||
tracing::info!("Removing invalid subscription: {}", subscription.endpoint);
|
tracing::info!("Removing problematic subscription after delivery failure: {}", subscription.endpoint);
|
||||||
let _ = store.remove_subscription(&subscription.endpoint).await;
|
let _ = store.remove_subscription(&subscription.endpoint).await;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
let err_debug = format!("{:?}", e);
|
let err_msg = format!("{:?}", e);
|
||||||
let err_display = format!("{}", e);
|
tracing::error!("Encryption/Build failed for {}: {}", subscription.endpoint, err_msg);
|
||||||
tracing::error!("Failed to build push message for {}: (Debug: {}) (Display: {})", subscription.endpoint, err_debug, err_display);
|
// Always remove on encryption failure
|
||||||
|
tracing::info!("Removing problematic subscription after encryption failure: {}", subscription.endpoint);
|
||||||
// Broaden error matching to catch various encryption and auth failures
|
let _ = store.remove_subscription(&subscription.endpoint).await;
|
||||||
let is_critical_error = err_debug.to_lowercase().contains("encrypt")
|
|
||||||
|| err_debug.to_lowercase().contains("vapid")
|
|
||||||
|| err_debug.to_lowercase().contains("unauthorized")
|
|
||||||
|| err_debug.to_lowercase().contains("unknown error");
|
|
||||||
|
|
||||||
if is_critical_error {
|
|
||||||
tracing::warn!("Critical push error detected, removing invalid subscription: {}", subscription.endpoint);
|
|
||||||
let _ = store.remove_subscription(&subscription.endpoint).await;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user