Compare commits
8 Commits
release-20
...
release-20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4e81565ab6 | ||
|
|
795eef4bda | ||
|
|
3ad8424d17 | ||
|
|
83feb5a5cf | ||
|
|
0dd97f3d7e | ||
|
|
bb32c1f7f6 | ||
|
|
3bb2d68a65 | ||
|
|
fe117cdaec |
@@ -16,9 +16,15 @@ pub async fn torrent_finished_handler(
|
|||||||
State(state): State<AppState>,
|
State(state): State<AppState>,
|
||||||
Query(params): Query<TorrentFinishedQuery>,
|
Query(params): Query<TorrentFinishedQuery>,
|
||||||
) -> StatusCode {
|
) -> StatusCode {
|
||||||
tracing::info!("Torrent finished notification received: {} ({})", params.name, params.hash);
|
tracing::info!("WEBHOOK: Received notification from rTorrent. Name: {:?}, Hash: {:?}", params.name, params.hash);
|
||||||
|
|
||||||
let message = format!("Torrent tamamlandı: {}", params.name);
|
let torrent_name = if params.name.is_empty() || params.name == "$d.name=" {
|
||||||
|
"Bilinmeyen Torrent".to_string()
|
||||||
|
} else {
|
||||||
|
params.name.clone()
|
||||||
|
};
|
||||||
|
|
||||||
|
let message = format!("Torrent tamamlandı: {}", torrent_name);
|
||||||
|
|
||||||
// 1. Send to active SSE clients (for Toast)
|
// 1. Send to active SSE clients (for Toast)
|
||||||
let notification = SystemNotification {
|
let notification = SystemNotification {
|
||||||
@@ -33,9 +39,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 name_for_log = torrent_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: {}", name_for_log);
|
||||||
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 task completed for: {}", name_for_log),
|
||||||
|
Err(e) => tracing::error!("Failed to send Web Push notification for {}: {:?}", name_for_log, 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
|
||||||
|
|||||||
@@ -191,11 +191,21 @@ 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);
|
||||||
|
tracing::error!("Delivery failed for {}: {}", subscription.endpoint, err_msg);
|
||||||
|
// Always remove on delivery failure (Gone, Unauthorized, etc.)
|
||||||
|
tracing::info!("Removing problematic subscription after delivery failure: {}", subscription.endpoint);
|
||||||
|
let _ = store.remove_subscription(&subscription.endpoint).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => tracing::error!("Failed to build push message: {}", e),
|
Err(e) => {
|
||||||
|
let err_msg = format!("{:?}", e);
|
||||||
|
tracing::error!("Encryption/Build failed for {}: {}", subscription.endpoint, err_msg);
|
||||||
|
// Always remove on encryption failure
|
||||||
|
tracing::info!("Removing problematic subscription after encryption failure: {}", 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