Compare commits
3 Commits
release-20
...
release-20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bb32c1f7f6 | ||
|
|
3bb2d68a65 | ||
|
|
fe117cdaec |
@@ -33,9 +33,13 @@ pub async fn torrent_finished_handler(
|
|||||||
let push_store = state.push_store.clone();
|
let push_store = state.push_store.clone();
|
||||||
let title = "Torrent Tamamlandı".to_string();
|
let title = "Torrent Tamamlandı".to_string();
|
||||||
let body = message;
|
let body = message;
|
||||||
|
let torrent_name = params.name.clone();
|
||||||
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
if let Err(e) = crate::push::send_push_notification(&push_store, &title, &body).await {
|
tracing::info!("Attempting to send Web Push notification for torrent: {}", torrent_name);
|
||||||
tracing::error!("Failed to send push notification from webhook: {}", e);
|
match crate::push::send_push_notification(&push_store, &title, &body).await {
|
||||||
|
Ok(_) => tracing::info!("Web Push notification sent successfully for: {}", torrent_name),
|
||||||
|
Err(e) => tracing::error!("Failed to send Web Push notification for {}: {:?}", torrent_name, e),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ async fn main() {
|
|||||||
let loop_interval = if active_clients > 0 {
|
let loop_interval = if active_clients > 0 {
|
||||||
Duration::from_secs(1)
|
Duration::from_secs(1)
|
||||||
} else {
|
} else {
|
||||||
Duration::from_secs(30)
|
Duration::from_secs(60)
|
||||||
};
|
};
|
||||||
|
|
||||||
// 1. Fetch Torrents
|
// 1. Fetch Torrents
|
||||||
|
|||||||
@@ -192,10 +192,22 @@ pub async fn send_push_notification(
|
|||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
tracing::error!("Failed to send push notification to {}: {}", subscription.endpoint, 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),
|
Err(e) => tracing::error!("Failed to build VAPID signature: {}", e),
|
||||||
|
|||||||
Reference in New Issue
Block a user